diff options
| author | bors <bors@rust-lang.org> | 2014-09-16 23:26:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-09-16 23:26:11 +0000 |
| commit | 0e784e16840e8a0c623cc6166de26da9334db3d6 (patch) | |
| tree | cb9ee37525225e3cbe4cda7d7954f2f72d24acb8 /src/libsyntax/util/small_vector.rs | |
| parent | ceb9bbfbf5933f9df238fecdd14e75304439c4f4 (diff) | |
| parent | fc525eeb4ec3443d29bce677f589b19f31c189bb (diff) | |
| download | rust-0e784e16840e8a0c623cc6166de26da9334db3d6.tar.gz rust-0e784e16840e8a0c623cc6166de26da9334db3d6.zip | |
auto merge of #17268 : aturon/rust/mut-conventions, r=alexcrichton
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. Additional details and motivation in the RFC. Note that the iterator *type* names are not changed by this RFC; those are awaiting a separate RFC for standardization. Closes #13660 Closes #16810 [breaking-change]
Diffstat (limited to 'src/libsyntax/util/small_vector.rs')
| -rw-r--r-- | src/libsyntax/util/small_vector.rs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/libsyntax/util/small_vector.rs b/src/libsyntax/util/small_vector.rs index 47aef987a63..a3f081e7be4 100644 --- a/src/libsyntax/util/small_vector.rs +++ b/src/libsyntax/util/small_vector.rs @@ -90,7 +90,7 @@ impl<T> SmallVector<T> { } pub fn push_all(&mut self, other: SmallVector<T>) { - for v in other.move_iter() { + for v in other.into_iter() { self.push(v); } } @@ -108,7 +108,7 @@ impl<T> SmallVector<T> { One(v) => v, Many(v) => { if v.len() == 1 { - v.move_iter().next().unwrap() + v.into_iter().next().unwrap() } else { fail!(err) } @@ -117,11 +117,17 @@ impl<T> SmallVector<T> { } } + /// Deprecated: use `into_iter`. + #[deprecated = "use into_iter"] pub fn move_iter(self) -> MoveItems<T> { + self.into_iter() + } + + pub fn into_iter(self) -> MoveItems<T> { let repr = match self.repr { Zero => ZeroIterator, One(v) => OneIterator(v), - Many(vs) => ManyIterator(vs.move_iter()) + Many(vs) => ManyIterator(vs.into_iter()) }; MoveItems { repr: repr } } @@ -202,7 +208,7 @@ mod test { #[test] fn test_from_iter() { - let v: SmallVector<int> = (vec!(1i, 2, 3)).move_iter().collect(); + let v: SmallVector<int> = (vec!(1i, 2, 3)).into_iter().collect(); assert_eq!(3, v.len()); assert_eq!(&1, v.get(0)); assert_eq!(&2, v.get(1)); @@ -212,14 +218,14 @@ mod test { #[test] fn test_move_iter() { let v = SmallVector::zero(); - let v: Vec<int> = v.move_iter().collect(); + let v: Vec<int> = v.into_iter().collect(); assert_eq!(Vec::new(), v); let v = SmallVector::one(1i); - assert_eq!(vec!(1i), v.move_iter().collect()); + assert_eq!(vec!(1i), v.into_iter().collect()); let v = SmallVector::many(vec!(1i, 2i, 3i)); - assert_eq!(vec!(1i, 2i, 3i), v.move_iter().collect()); + assert_eq!(vec!(1i, 2i, 3i), v.into_iter().collect()); } #[test] |
