Skip to content

Commit

Permalink
chore: extract complex match block into a variable (clippy suggestion)
Browse files Browse the repository at this point in the history
Based on this clippy lint:

> in a `match` scrutinee, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let`
  • Loading branch information
thomasheartman committed Mar 14, 2024
1 parent a8a45f7 commit 26eaac3
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ where
let default_context = &Default::default();
let context = context.unwrap_or(default_context);

match (|| {
let feature_enabled = {
if feature.strategies.is_empty() && feature.known && !feature.feature_disabled {
trace!(
"is_enabled: feature {:?} has no strategies: enabling",
Expand Down Expand Up @@ -307,15 +307,14 @@ where
);
false
}
})() {
true => {
feature.enabled.fetch_add(1, Ordering::Relaxed);
true
}
false => {
feature.disabled.fetch_add(1, Ordering::Relaxed);
false
}
};

if feature_enabled {
feature.enabled.fetch_add(1, Ordering::Relaxed);
true
} else {
feature.disabled.fetch_add(1, Ordering::Relaxed);
false
}
}

Expand Down

0 comments on commit 26eaac3

Please sign in to comment.