Skip to content

Commit

Permalink
Derive Clone for Peekable
Browse files Browse the repository at this point in the history
  • Loading branch information
apasel422 committed Sep 29, 2015
1 parent 5f06607 commit 532ee3c
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/libcore/iter.rs
Expand Up @@ -1862,22 +1862,14 @@ impl<I> DoubleEndedIterator for Enumerate<I> where
}

/// An iterator with a `peek()` that returns an optional reference to the next element.
#[derive(Clone)]
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Peekable<I: Iterator> {
iter: I,
peeked: Option<I::Item>,
}

impl<I: Iterator + Clone> Clone for Peekable<I> where I::Item: Clone {
fn clone(&self) -> Peekable<I> {
Peekable {
iter: self.iter.clone(),
peeked: self.peeked.clone(),
}
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<I: Iterator> Iterator for Peekable<I> {
type Item = I::Item;
Expand Down

0 comments on commit 532ee3c

Please sign in to comment.