Skip to content

Commit

Permalink
Update PeekNth::peek_nth doctest
Browse files Browse the repository at this point in the history
Use `into_iter` instead to avoid `&&`.
I did the same in `PeekNth::peek_nth_mut` to avoid `&mut &`.
  • Loading branch information
Philippe-Cholet committed Oct 9, 2023
1 parent 554ee73 commit 7748ee4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/peek_nth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ where
///
/// Basic usage:
///
/// ```rust
/// ```
/// use itertools::peek_nth;
///
/// let xs = vec![1,2,3];
/// let mut iter = peek_nth(xs.iter());
/// let xs = vec![1, 2, 3];
/// let mut iter = peek_nth(xs.into_iter());
///
/// assert_eq!(iter.peek_nth(0), Some(&&1));
/// assert_eq!(iter.next(), Some(&1));
/// assert_eq!(iter.peek_nth(0), Some(&1));
/// assert_eq!(iter.next(), Some(1));
///
/// // The iterator does not advance even if we call `peek_nth` multiple times
/// assert_eq!(iter.peek_nth(0), Some(&&2));
/// assert_eq!(iter.peek_nth(1), Some(&&3));
/// assert_eq!(iter.next(), Some(&2));
/// assert_eq!(iter.peek_nth(0), Some(&2));
/// assert_eq!(iter.peek_nth(1), Some(&3));
/// assert_eq!(iter.next(), Some(2));
///
/// // Calling `peek_nth` past the end of the iterator will return `None`
/// assert_eq!(iter.peek_nth(1), None);
Expand Down

0 comments on commit 7748ee4

Please sign in to comment.