diff options
| author | Aaron Turon <aturon@mozilla.com> | 2014-09-14 15:57:55 -0700 |
|---|---|---|
| committer | Aaron Turon <aturon@mozilla.com> | 2014-09-16 11:46:52 -0700 |
| commit | d8dfe1957b6541de8fe2797e248fe4bd2fac02d9 (patch) | |
| tree | a6e36c294538942b621d79f28424caa02a093a59 /src/libstd | |
| parent | 828e075abd8ee2f8c16f6cb1b93c0d99307e704d (diff) | |
| download | rust-d8dfe1957b6541de8fe2797e248fe4bd2fac02d9.tar.gz rust-d8dfe1957b6541de8fe2797e248fe4bd2fac02d9.zip | |
Align with _mut conventions
As per [RFC 52](https://github.com/rust-lang/rfcs/blob/master/active/0052-ownership-variants.md), use `_mut` suffixes to mark mutable variants, and `into_iter` for moving iterators. [breaking-change]
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/collections/hashmap/map.rs | 16 | ||||
| -rw-r--r-- | src/libstd/collections/hashmap/table.rs | 4 | ||||
| -rw-r--r-- | src/libstd/io/buffered.rs | 2 |
3 files changed, 17 insertions, 5 deletions
diff --git a/src/libstd/collections/hashmap/map.rs b/src/libstd/collections/hashmap/map.rs index a50c6a59f7e..4a58f4e75de 100644 --- a/src/libstd/collections/hashmap/map.rs +++ b/src/libstd/collections/hashmap/map.rs @@ -1193,6 +1193,12 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> { Entries { inner: self.table.iter() } } + /// Deprecated: use `iter_mut`. + #[deprecated = "use iter_mut"] + pub fn mut_iter(&mut self) -> MutEntries<K, V> { + self.iter_mut() + } + /// An iterator visiting all key-value pairs in arbitrary order, /// with mutable references to the values. /// Iterator element type is `(&'a K, &'a mut V)`. @@ -1216,10 +1222,16 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> { /// println!("key: {} val: {}", key, val); /// } /// ``` - pub fn mut_iter(&mut self) -> MutEntries<K, V> { + pub fn iter_mut(&mut self) -> MutEntries<K, V> { MutEntries { inner: self.table.mut_iter() } } + /// Deprecated: use `into_iter`. + #[deprecated = "use into_iter"] + pub fn move_iter(self) -> MoveEntries<K, V> { + self.into_iter() + } + /// Creates a consuming iterator, that is, one that moves each key-value /// pair out of the map in arbitrary order. The map cannot be used after /// calling this. @@ -1237,7 +1249,7 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> { /// // Not possible with .iter() /// let vec: Vec<(&str, int)> = map.move_iter().collect(); /// ``` - pub fn move_iter(self) -> MoveEntries<K, V> { + pub fn into_iter(self) -> MoveEntries<K, V> { MoveEntries { inner: self.table.move_iter().map(|(_, k, v)| (k, v)) } diff --git a/src/libstd/collections/hashmap/table.rs b/src/libstd/collections/hashmap/table.rs index 2edb8cd092e..33e760f11ce 100644 --- a/src/libstd/collections/hashmap/table.rs +++ b/src/libstd/collections/hashmap/table.rs @@ -674,14 +674,14 @@ impl<K, V> RawTable<K, V> { } } - pub fn mut_iter(&mut self) -> MutEntries<K, V> { + pub fn iter_mut(&mut self) -> MutEntries<K, V> { MutEntries { iter: self.raw_buckets(), elems_left: self.size(), } } - pub fn move_iter(self) -> MoveEntries<K, V> { + pub fn into_iter(self) -> MoveEntries<K, V> { MoveEntries { iter: self.raw_buckets(), table: self, diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 0c63f1a901f..76f86d66ff5 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -265,7 +265,7 @@ impl<W: Writer> Writer for LineBufferedWriter<W> { struct InternalBufferedWriter<W>(BufferedWriter<W>); impl<W> InternalBufferedWriter<W> { - fn get_mut_ref<'a>(&'a mut self) -> &'a mut BufferedWriter<W> { + fn get_mut<'a>(&'a mut self) -> &'a mut BufferedWriter<W> { let InternalBufferedWriter(ref mut w) = *self; return w; } |
