Skip to content

Commit

Permalink
Use last_mut()? instead of indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
ronnodas committed Jan 16, 2025
1 parent 3dd45f5 commit 5a7c522
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/permutations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ where
PermutationState::Buffered { indices, min_n } => {
let k = indices.len();
if vals.get_next() {
indices.borrow_mut()[k.value() - 1] += 1;
// This could be an unwrap instead of ?, indices.len() should be
// k.value() > 0 to be in this case
*indices.borrow_mut().last_mut()? += 1;
debug_assert!(indices
.borrow()
.iter()
Expand Down

0 comments on commit 5a7c522

Please sign in to comment.