Skip to content

Commit

Permalink
impl FusedIterator for Permutations
Browse files Browse the repository at this point in the history
The lazy buffer fuses the iterator so `I` does not have to be fused.
  • Loading branch information
Philippe-Cholet committed Oct 30, 2023
1 parent 06721b8 commit 4f049ca
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/permutations.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use alloc::vec::Vec;
use std::fmt;
use std::iter::once;
use std::iter::FusedIterator;

use super::lazy_buffer::LazyBuffer;
use crate::size_hint::{self, SizeHint};
Expand Down Expand Up @@ -131,6 +132,13 @@ where
}
}

impl<I> FusedIterator for Permutations<I>
where
I: Iterator,
I::Item: Clone,
{
}

fn advance(indices: &mut [usize], cycles: &mut [usize]) -> bool {
let n = indices.len();
let k = cycles.len();
Expand Down

0 comments on commit 4f049ca

Please sign in to comment.