diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-12-30 16:26:15 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-12-30 16:26:15 -0800 |
| commit | a8820f7a2df1932918dbaa5d123486d86f7fb008 (patch) | |
| tree | e4d6d36b5710f4b707472017c823aefb14cfd960 /src/libstd/collections/hash/map.rs | |
| parent | 899eb65b29bf666b05b155a3d4cc6002ac8cb26a (diff) | |
| parent | b7832ed0b42a2d6512e3f8d09605986237f02ed5 (diff) | |
| download | rust-a8820f7a2df1932918dbaa5d123486d86f7fb008.tar.gz rust-a8820f7a2df1932918dbaa5d123486d86f7fb008.zip | |
rollup merge of #20328: huonw/attack-of-the-clones
It's useful to be able to save state.
Diffstat (limited to 'src/libstd/collections/hash/map.rs')
| -rw-r--r-- | src/libstd/collections/hash/map.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index b473a665c76..8181ea5253f 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1319,6 +1319,15 @@ pub struct Iter<'a, K: 'a, V: 'a> { inner: table::Iter<'a, K, V> } +// FIXME(#19839) Remove in favor of `#[deriving(Clone)]` +impl<'a, K, V> Clone for Entries<'a, K, V> { + fn clone(&self) -> Entries<'a, K, V> { + Entries { + inner: self.inner.clone() + } + } +} + /// HashMap mutable values iterator pub struct IterMut<'a, K: 'a, V: 'a> { inner: table::IterMut<'a, K, V> @@ -1339,11 +1348,29 @@ pub struct Keys<'a, K: 'a, V: 'a> { inner: Map<(&'a K, &'a V), &'a K, Iter<'a, K, V>, fn((&'a K, &'a V)) -> &'a K> } +// FIXME(#19839) Remove in favor of `#[deriving(Clone)]` +impl<'a, K, V> Clone for Keys<'a, K, V> { + fn clone(&self) -> Keys<'a, K, V> { + Keys { + inner: self.inner.clone() + } + } +} + /// HashMap values iterator pub struct Values<'a, K: 'a, V: 'a> { inner: Map<(&'a K, &'a V), &'a V, Iter<'a, K, V>, fn((&'a K, &'a V)) -> &'a V> } +// FIXME(#19839) Remove in favor of `#[deriving(Clone)]` +impl<'a, K, V> Clone for Values<'a, K, V> { + fn clone(&self) -> Values<'a, K, V> { + Values { + inner: self.inner.clone() + } + } +} + /// HashMap drain iterator pub struct Drain<'a, K: 'a, V: 'a> { inner: iter::Map< |
