Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use derive macro for impl Clone #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 3 additions & 31 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,7 @@ macro_rules! double_ended_iterator {
}

/// An iterator over the key-value pairs of a map.
#[derive(Clone)]
pub struct Iter<'a, V> {
front: usize,
back: usize,
Expand All @@ -920,19 +921,6 @@ pub struct Iter<'a, V> {
iter: slice::Iter<'a, Option<V>>,
}

// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
impl<'a, V> Clone for Iter<'a, V> {
fn clone(&self) -> Iter<'a, V> {
Iter {
front: self.front,
back: self.back,
n: self.n,
yielded: self.yielded,
iter: self.iter.clone(),
}
}
}

iterator! { impl Iter -> (usize, &'a V), as_ref }
impl<'a, V> ExactSizeIterator for Iter<'a, V> {}
double_ended_iterator! { impl Iter -> (usize, &'a V), as_ref }
Expand All @@ -952,33 +940,17 @@ impl<'a, V> ExactSizeIterator for IterMut<'a, V> {}
double_ended_iterator! { impl IterMut -> (usize, &'a mut V), as_mut }

/// An iterator over the keys of a map.
#[derive(Clone)]
pub struct Keys<'a, V> {
iter: Iter<'a, V>,
}

// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
impl<'a, V> Clone for Keys<'a, V> {
fn clone(&self) -> Keys<'a, V> {
Keys {
iter: self.iter.clone(),
}
}
}

/// An iterator over the values of a map.
#[derive(Clone)]
pub struct Values<'a, V> {
iter: Iter<'a, V>,
}

// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
impl<'a, V> Clone for Values<'a, V> {
fn clone(&self) -> Values<'a, V> {
Values {
iter: self.iter.clone(),
}
}
}

/// An iterator over the values of a map.
pub struct ValuesMut<'a, V> {
iter_mut: IterMut<'a, V>,
Expand Down