Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Prefer first() over get(0) #334

Merged
merged 1 commit into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/src/client/transport/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl TransportState {
});
let mut ret = Vec::with_capacity(chunks.len());
let mut expect_sequence_number = chunks
.get(0)
.first()
.unwrap()
.header
.sequence_header
Expand Down
4 changes: 2 additions & 2 deletions samples/demo-server/src/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl callbacks::Method for Boop {
// Validate input to be a string
debug!("Boop method called");
let in1_status = if let Some(ref input_arguments) = request.input_arguments {
if let Some(in1) = input_arguments.get(0) {
if let Some(in1) = input_arguments.first() {
if let Variant::String(_) = in1 {
StatusCode::Good
} else {
Expand Down Expand Up @@ -152,7 +152,7 @@ impl callbacks::Method for HelloX {
// Validate input to be a string
let mut out1 = Variant::Empty;
let in1_status = if let Some(ref input_arguments) = request.input_arguments {
if let Some(in1) = input_arguments.get(0) {
if let Some(in1) = input_arguments.first() {
if let Variant::String(in1) = in1 {
out1 = Variant::from(format!("Hello {}!", &in1));
StatusCode::Good
Expand Down
6 changes: 3 additions & 3 deletions samples/demo-server/src/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ fn add_static_array_variables(server: &mut Server, ns: u16, static_folder_id: &N
.map(|_| scalar_default_value(*sn))
.collect::<Vec<Variant>>();

let value_type = values.get(0).unwrap().type_id();
let value_type = values.first().unwrap().type_id();
VariableBuilder::new(&node_id, name, name)
.data_type(*sn)
.value_rank(1)
Expand Down Expand Up @@ -254,7 +254,7 @@ fn add_dynamic_array_variables(server: &mut Server, ns: u16, dynamic_folder_id:
let values = (0..10)
.map(|_| scalar_default_value(*sn))
.collect::<Vec<Variant>>();
let value_type = values.get(0).unwrap().type_id();
let value_type = values.first().unwrap().type_id();
VariableBuilder::new(&node_id, name, name)
.data_type(*sn)
.value_rank(1)
Expand Down Expand Up @@ -285,7 +285,7 @@ fn set_dynamic_timers(server: &mut Server, ns: u16) {
let values = (0..10)
.map(|_| scalar_random_value(*sn))
.collect::<Vec<Variant>>();
let value_type = values.get(0).unwrap().type_id();
let value_type = values.first().unwrap().type_id();
let _ =
address_space.set_variable_value_by_ref(&node_id, (value_type, values), &now, &now);
});
Expand Down
4 changes: 2 additions & 2 deletions samples/web-client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ impl OPCUASession {
if args.len() != 3 {
return;
}
let event_node_id = args.get(0).unwrap();
let event_node_id = args.first().unwrap();
let where_clause = args.get(1).unwrap();
let select_criteria = args.get(2).unwrap();

Expand All @@ -322,7 +322,7 @@ impl OPCUASession {
return;
}
// Left and right operands
let lhs_str = where_parts.get(0).unwrap();
let lhs_str = where_parts.first().unwrap();
let operator = where_parts.get(1).unwrap();
let rhs_str = where_parts.get(2).unwrap();

Expand Down
Loading