diff options
| author | Brendan Zabarauskas <bjzaba@yahoo.com.au> | 2014-02-16 20:36:43 +1100 |
|---|---|---|
| committer | Brendan Zabarauskas <bjzaba@yahoo.com.au> | 2014-02-17 00:57:56 +1100 |
| commit | f450b2b379794ba9f367f9dadbd2d70913da8560 (patch) | |
| tree | a87a5ecceb67042fc962f0cc372c8cf950482ba2 /src/libstd | |
| parent | cf0654c47c0d47478cdafec89ae250a86b4f2c17 (diff) | |
| download | rust-f450b2b379794ba9f367f9dadbd2d70913da8560.tar.gz rust-f450b2b379794ba9f367f9dadbd2d70913da8560.zip | |
Remove CloneableTuple and ImmutableTuple traits
These are adequately covered by the Tuple2 trait.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/iter.rs | 2 | ||||
| -rw-r--r-- | src/libstd/prelude.rs | 1 | ||||
| -rw-r--r-- | src/libstd/str.rs | 6 | ||||
| -rw-r--r-- | src/libstd/tuple.rs | 77 |
4 files changed, 5 insertions, 81 deletions
diff --git a/src/libstd/iter.rs b/src/libstd/iter.rs index d141da68dfd..e5a89fc42e1 100644 --- a/src/libstd/iter.rs +++ b/src/libstd/iter.rs @@ -2611,7 +2611,7 @@ mod tests { assert_eq!(vi.size_hint(), (10, Some(10))); assert_eq!(c.take(5).size_hint(), (5, Some(5))); - assert_eq!(c.skip(5).size_hint().second(), None); + assert_eq!(c.skip(5).size_hint().val1(), None); assert_eq!(c.take_while(|_| false).size_hint(), (0, None)); assert_eq!(c.skip_while(|_| false).size_hint(), (0, None)); assert_eq!(c.enumerate().size_hint(), (uint::MAX, None)); diff --git a/src/libstd/prelude.rs b/src/libstd/prelude.rs index ef159d68df7..bd21bb4e754 100644 --- a/src/libstd/prelude.rs +++ b/src/libstd/prelude.rs @@ -67,7 +67,6 @@ pub use io::{Buffer, Writer, Reader, Seek}; pub use str::{Str, StrVector, StrSlice, OwnedStr, IntoMaybeOwned}; pub use to_bytes::IterBytes; pub use to_str::{ToStr, IntoStr}; -pub use tuple::{CloneableTuple, ImmutableTuple}; pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4}; pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8}; pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12}; diff --git a/src/libstd/str.rs b/src/libstd/str.rs index 023900e5d41..0a7f513581c 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -567,14 +567,14 @@ impl<'a> Iterator<&'a str> for StrSplits<'a> { // Helper functions used for Unicode normalization fn canonical_sort(comb: &mut [(char, u8)]) { use iter::range; - use tuple::CloneableTuple; + use tuple::Tuple2; let len = comb.len(); for i in range(0, len) { let mut swapped = false; for j in range(1, len-i) { - let classA = comb[j-1].second(); - let classB = comb[j].second(); + let classA = *comb[j-1].ref1(); + let classB = *comb[j].ref1(); if classA != 0 && classB != 0 && classA > classB { comb.swap(j-1, j); swapped = true; diff --git a/src/libstd/tuple.rs b/src/libstd/tuple.rs index 91625a53c94..7a81e69f30a 100644 --- a/src/libstd/tuple.rs +++ b/src/libstd/tuple.rs @@ -19,66 +19,6 @@ use fmt; use result::{Ok, Err}; use to_str::ToStr; -/// Method extensions to pairs where both types satisfy the `Clone` bound -pub trait CloneableTuple<T, U> { - /// Return the first element of self - fn first(&self) -> T; - /// Return the second element of self - fn second(&self) -> U; - /// Return the results of swapping the two elements of self - fn swap(&self) -> (U, T); -} - -impl<T:Clone,U:Clone> CloneableTuple<T, U> for (T, U) { - /// Return the first element of self - #[inline] - fn first(&self) -> T { - match *self { - (ref t, _) => (*t).clone(), - } - } - - /// Return the second element of self - #[inline] - fn second(&self) -> U { - match *self { - (_, ref u) => (*u).clone(), - } - } - - /// Return the results of swapping the two elements of self - #[inline] - fn swap(&self) -> (U, T) { - match (*self).clone() { - (t, u) => (u, t), - } - } -} - -/// Method extensions for pairs where the types don't necessarily satisfy the -/// `Clone` bound -pub trait ImmutableTuple<T, U> { - /// Return a reference to the first element of self - fn first_ref<'a>(&'a self) -> &'a T; - /// Return a reference to the second element of self - fn second_ref<'a>(&'a self) -> &'a U; -} - -impl<T, U> ImmutableTuple<T, U> for (T, U) { - #[inline] - fn first_ref<'a>(&'a self) -> &'a T { - match *self { - (ref t, _) => t, - } - } - #[inline] - fn second_ref<'a>(&'a self) -> &'a U { - match *self { - (_, ref u) => u, - } - } -} - // macro for implementing n-ary tuple functions and operations macro_rules! tuple_impls { ($( @@ -340,25 +280,10 @@ mod tests { use cmp::*; #[test] - fn test_tuple_ref() { - let x = (~"foo", ~"bar"); - assert_eq!(x.first_ref(), &~"foo"); - assert_eq!(x.second_ref(), &~"bar"); - } - - #[test] - fn test_tuple() { - assert_eq!((948, 4039.48).first(), 948); - assert_eq!((34.5, ~"foo").second(), ~"foo"); - assert_eq!(('a', 2).swap(), (2, 'a')); - } - - #[test] fn test_clone() { let a = (1, ~"2"); let b = a.clone(); - assert_eq!(a.first(), b.first()); - assert_eq!(a.second(), b.second()); + assert_eq!(a, b); } #[test] |
