-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
S-needs-discussionStatus: Needs further discussion before merging or work can be startedStatus: Needs further discussion before merging or work can be started
Description
This lint I don't quite agree with, and I realize opinions will differ on this.
Existing code in removed (red) and the proposed change by clippy in added (green) lines:
// clear edges without touching the free list
for node in &mut self.g.nodes {
- if let Some(_) = node.weight {
+ if node.weight.is_some() {
node.next = [EdgeIndex::end(), EdgeIndex::end()];
}
}
- if let None = node_weight {
+ if node_weight.is_none() {
return None;
}
etc with similar examples.
I think that using if let
is fundamental to Rust, is general, works with any enum and is just as easy to understand as the alternative. I prefer general over Option-specific methods.
Metadata
Metadata
Assignees
Labels
S-needs-discussionStatus: Needs further discussion before merging or work can be startedStatus: Needs further discussion before merging or work can be started