Skip to content

Commit

Permalink
favor expect over commented unwraps
Browse files Browse the repository at this point in the history
  • Loading branch information
JayKickliter committed Sep 25, 2024
1 parent d3dd4d1 commit 5369ab5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,13 @@ impl Cell {
#[inline]
pub fn is_related_to(&self, other: &Self) -> bool {
let common_res = std::cmp::min(self.res(), other.res());
// Unwrap is fine. We already checked to the min common resolution.
self.to_parent(common_res).unwrap() == other.to_parent(common_res).unwrap()
let promoted_self = self
.to_parent(common_res)
.expect("we already checked to the min common resolution");
let promoted_other = other
.to_parent(common_res)
.expect("we already checked to the min common resolution");
promoted_self == promoted_other
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ where
}) => cell_value,
Entry::Vacant(VacantEntry { target_cell, map }) => {
map.insert(target_cell, Default::default());
// We just inserted; unwrap is fine.
map.get_mut(target_cell).unwrap()
map.get_mut(target_cell).expect("we just inserted")
}
}
}
Expand Down

0 comments on commit 5369ab5

Please sign in to comment.