diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-10-30 13:43:24 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-11-01 11:37:04 -0700 |
| commit | 21ac985af44f4e2470ef6f4c0eb4d72daf5a6497 (patch) | |
| tree | a120c184188926cd154b40f9da77ad8a6a455c1b /src/libsyntax | |
| parent | 1442235d3feab4c5ca3f55e2b3345583f640a17e (diff) | |
| download | rust-21ac985af44f4e2470ef6f4c0eb4d72daf5a6497.tar.gz rust-21ac985af44f4e2470ef6f4c0eb4d72daf5a6497.zip | |
collections: Remove all collections traits
As part of the collections reform RFC, this commit removes all collections traits in favor of inherent methods on collections themselves. All methods should continue to be available on all collections. This is a breaking change with all of the collections traits being removed and no longer being in the prelude. In order to update old code you should move the trait implementations to inherent implementations directly on the type itself. Note that some traits had default methods which will also need to be implemented to maintain backwards compatibility. [breaking-change] cc #18424
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/owned_slice.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/util/small_vector.rs | 20 |
2 files changed, 14 insertions, 14 deletions
diff --git a/src/libsyntax/owned_slice.rs b/src/libsyntax/owned_slice.rs index 4f09b34557c..f622e2d6112 100644 --- a/src/libsyntax/owned_slice.rs +++ b/src/libsyntax/owned_slice.rs @@ -112,6 +112,10 @@ impl<T> OwnedSlice<T> { pub fn map<U>(&self, f: |&T| -> U) -> OwnedSlice<U> { self.iter().map(f).collect() } + + pub fn len(&self) -> uint { self.len } + + pub fn is_empty(&self) -> bool { self.len == 0 } } impl<T> Default for OwnedSlice<T> { @@ -140,10 +144,6 @@ impl<T: PartialEq> PartialEq for OwnedSlice<T> { impl<T: Eq> Eq for OwnedSlice<T> {} -impl<T> Collection for OwnedSlice<T> { - fn len(&self) -> uint { self.len } -} - impl<T> FromIterator<T> for OwnedSlice<T> { fn from_iter<I: Iterator<T>>(mut iter: I) -> OwnedSlice<T> { OwnedSlice::from_vec(iter.collect()) diff --git a/src/libsyntax/util/small_vector.rs b/src/libsyntax/util/small_vector.rs index 422c2d5c75b..56ee6c7b915 100644 --- a/src/libsyntax/util/small_vector.rs +++ b/src/libsyntax/util/small_vector.rs @@ -25,16 +25,6 @@ enum SmallVectorRepr<T> { Many(Vec<T>), } -impl<T> Collection for SmallVector<T> { - fn len(&self) -> uint { - match self.repr { - Zero => 0, - One(..) => 1, - Many(ref vals) => vals.len() - } - } -} - impl<T> FromIterator<T> for SmallVector<T> { fn from_iter<I: Iterator<T>>(iter: I) -> SmallVector<T> { let mut v = SmallVector::zero(); @@ -131,6 +121,16 @@ impl<T> SmallVector<T> { }; MoveItems { repr: repr } } + + pub fn len(&self) -> uint { + match self.repr { + Zero => 0, + One(..) => 1, + Many(ref vals) => vals.len() + } + } + + pub fn is_empty(&self) -> bool { self.len() == 0 } } pub struct MoveItems<T> { |
