Skip to content

Commit

Permalink
Merge #427
Browse files Browse the repository at this point in the history
427: Style updates r=samueltardieu a=samueltardieu

- Do not use `bool::then()` in `filter_map()`
- Use `or_default()` rather than `or_insert_with()` with default value


Co-authored-by: Samuel Tardieu <sam@rfc1149.net>
  • Loading branch information
bors[bot] and samueltardieu authored Jul 27, 2023
2 parents 09cf00e + 07d50d8 commit 725e534
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/directed/edmonds_karp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ unsafe impl<C: Send> Send for SparseCapacity<C> {}
impl<C: Copy + Eq + Zero + Signed + Bounded + Ord> SparseCapacity<C> {
fn set_value(data: &mut BTreeMap<usize, BTreeMap<usize, C>>, from: usize, to: usize, value: C) {
let to_remove = {
let sub = data.entry(from).or_insert_with(BTreeMap::new);
let sub = data.entry(from).or_default();
if value == Zero::zero() {
sub.remove(&to);
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/directed/topological_sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ where
let mut groups = Vec::<Vec<N>>::new();
let mut prev_group: Vec<N> = preds_map
.iter()
.filter_map(|(node, &num_preds)| (num_preds == 0).then(|| node.clone()))
.filter(|(_, &num_preds)| num_preds == 0)
.map(|(node, _)| node.clone())
.collect();
if prev_group.is_empty() {
let remaining: Vec<N> = preds_map.into_keys().collect();
Expand Down

0 comments on commit 725e534

Please sign in to comment.