Skip to content

Commit

Permalink
refactor: Use is_empty instead of len() == 0 comparisons (#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
AiyionPrime authored Jul 23, 2024
1 parent ce9cd86 commit c75b1bb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/src/client/session/services/subscriptions/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ impl Session {
let acks = {
let mut subscription_state = trace_lock!(self.subscription_state);
let acks = subscription_state.take_acknowledgements();
if acks.len() > 0 {
if !acks.is_empty() {
Some(acks)
} else {
None
Expand Down
2 changes: 1 addition & 1 deletion lib/src/server/services/message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ impl MessageHandler {
let session_diagnostics = session.session_diagnostics();
let mut session_diagnostics = trace_write_lock!(session_diagnostics);
Self::diag_authorized_request(&mut session_diagnostics, authorized);
if diagnostic_key.len() > 0 {
if !diagnostic_key.is_empty() {
let service_success = if let SupportedMessage::ServiceFault(_response) = response {
false
} else {
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 @@ -94,7 +94,7 @@ impl callbacks::Method for Boop {
} else {
StatusCode::BadInvalidArgument
}
} else if input_arguments.len() == 0 {
} else if input_arguments.is_empty() {
return Err(StatusCode::BadArgumentsMissing);
} else {
// Shouldn't get here because there is 1 argument
Expand Down Expand Up @@ -159,7 +159,7 @@ impl callbacks::Method for HelloX {
} else {
StatusCode::BadTypeMismatch
}
} else if input_arguments.len() == 0 {
} else if input_arguments.is_empty() {
return Err(StatusCode::BadArgumentsMissing);
} else {
// Shouldn't get here because there is 1 argument
Expand Down

0 comments on commit c75b1bb

Please sign in to comment.