about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBrendan Zabarauskas <bjzaba@yahoo.com.au>2014-02-16 20:36:43 +1100
committerBrendan Zabarauskas <bjzaba@yahoo.com.au>2014-02-17 00:57:56 +1100
commitf450b2b379794ba9f367f9dadbd2d70913da8560 (patch)
treea87a5ecceb67042fc962f0cc372c8cf950482ba2 /src
parentcf0654c47c0d47478cdafec89ae250a86b4f2c17 (diff)
downloadrust-f450b2b379794ba9f367f9dadbd2d70913da8560.tar.gz
rust-f450b2b379794ba9f367f9dadbd2d70913da8560.zip
Remove CloneableTuple and ImmutableTuple traits
These are adequately covered by the Tuple2 trait.
Diffstat (limited to 'src')
-rw-r--r--src/etc/vim/syntax/rust.vim4
-rw-r--r--src/libnative/io/process.rs4
-rw-r--r--src/librustc/middle/trans/consts.rs2
-rw-r--r--src/librustc/middle/ty.rs2
-rw-r--r--src/libstd/iter.rs2
-rw-r--r--src/libstd/prelude.rs1
-rw-r--r--src/libstd/str.rs6
-rw-r--r--src/libstd/tuple.rs77
-rw-r--r--src/test/bench/task-perf-alloc-unwind.rs4
9 files changed, 11 insertions, 91 deletions
diff --git a/src/etc/vim/syntax/rust.vim b/src/etc/vim/syntax/rust.vim
index aac759e3950..03c67276049 100644
--- a/src/etc/vim/syntax/rust.vim
+++ b/src/etc/vim/syntax/rust.vim
@@ -95,13 +95,9 @@ syn keyword rustTrait Buffer Writer Reader Seek
 syn keyword rustTrait Str StrVector StrSlice OwnedStr IntoMaybeOwned
 syn keyword rustTrait IterBytes
 syn keyword rustTrait ToStr IntoStr
-syn keyword rustTrait CloneableTuple ImmutableTuple
 syn keyword rustTrait Tuple1 Tuple2 Tuple3 Tuple4
 syn keyword rustTrait Tuple5 Tuple6 Tuple7 Tuple8
 syn keyword rustTrait Tuple9 Tuple10 Tuple11 Tuple12
-syn keyword rustTrait ImmutableTuple1 ImmutableTuple2 ImmutableTuple3 ImmutableTuple4
-syn keyword rustTrait ImmutableTuple5 ImmutableTuple6 ImmutableTuple7 ImmutableTuple8
-syn keyword rustTrait ImmutableTuple9 ImmutableTuple10 ImmutableTuple11 ImmutableTuple12
 syn keyword rustTrait ImmutableEqVector ImmutableTotalOrdVector ImmutableCloneableVector
 syn keyword rustTrait OwnedVector OwnedCloneableVector OwnedEqVector MutableVector
 syn keyword rustTrait Vector VectorVector CloneableVector ImmutableVector
diff --git a/src/libnative/io/process.rs b/src/libnative/io/process.rs
index 2a061c5f9b2..b796535371f 100644
--- a/src/libnative/io/process.rs
+++ b/src/libnative/io/process.rs
@@ -529,7 +529,7 @@ fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: |*c_void| -> T) -> T {
             let mut tmps = vec::with_capacity(env.len());
 
             for pair in env.iter() {
-                let kv = format!("{}={}", pair.first(), pair.second());
+                let kv = format!("{}={}", *pair.ref0(), *pair.ref1());
                 tmps.push(kv.to_c_str());
             }
 
@@ -553,7 +553,7 @@ fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: |*mut c_void| -> T) -> T {
             let mut blk = ~[];
 
             for pair in env.iter() {
-                let kv = format!("{}={}", pair.first(), pair.second());
+                let kv = format!("{}={}", *pair.ref0(), *pair.ref1());
                 blk.push_all(kv.as_bytes());
                 blk.push(0);
             }
diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs
index 68be851449a..fc5e48a161f 100644
--- a/src/librustc/middle/trans/consts.rs
+++ b/src/librustc/middle/trans/consts.rs
@@ -599,7 +599,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: &ast::Expr,
                 const_eval::const_uint(i) => i as uint,
                 _ => cx.sess.span_bug(count.span, "count must be integral const expression.")
             };
-            let vs = vec::from_elem(n, const_expr(cx, elem, is_local).first());
+            let vs = vec::from_elem(n, const_expr(cx, elem, is_local).val0());
             let v = if vs.iter().any(|vi| val_ty(*vi) != llunitty) {
                 C_struct(vs, false)
             } else {
diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs
index 374f49a36be..0dcbfe491c3 100644
--- a/src/librustc/middle/ty.rs
+++ b/src/librustc/middle/ty.rs
@@ -4604,7 +4604,7 @@ pub fn determine_inherited_purity(parent: (ast::Purity, ast::NodeId),
     // purity inferred for it, then check it under its parent's purity.
     // Otherwise, use its own
     match child_sigil {
-        ast::BorrowedSigil if child.first() == ast::ImpureFn => parent,
+        ast::BorrowedSigil if child.val0() == ast::ImpureFn => parent,
         _ => child
     }
 }
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]
diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs
index 013df3b3675..51eb65b1d5c 100644
--- a/src/test/bench/task-perf-alloc-unwind.rs
+++ b/src/test/bench/task-perf-alloc-unwind.rs
@@ -90,8 +90,8 @@ fn recurse_or_fail(depth: int, st: Option<State>) {
             State {
                 managed: @Cons((), st.managed),
                 unique: ~Cons((), @*st.unique),
-                tuple: (@Cons((), st.tuple.first()),
-                        ~Cons((), @*st.tuple.second())),
+                tuple: (@Cons((), st.tuple.ref0().clone()),
+                        ~Cons((), @*st.tuple.ref1().clone())),
                 vec: st.vec + &[@Cons((), *st.vec.last().unwrap())],
                 res: r(@Cons((), st.res._l))
             }