Skip to content

Commit f450b2b

Browse files
committed
Remove CloneableTuple and ImmutableTuple traits
These are adequately covered by the Tuple2 trait.
1 parent cf0654c commit f450b2b

File tree

9 files changed

+11
-91
lines changed

9 files changed

+11
-91
lines changed

src/etc/vim/syntax/rust.vim

-4
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,9 @@ syn keyword rustTrait Buffer Writer Reader Seek
9595
syn keyword rustTrait Str StrVector StrSlice OwnedStr IntoMaybeOwned
9696
syn keyword rustTrait IterBytes
9797
syn keyword rustTrait ToStr IntoStr
98-
syn keyword rustTrait CloneableTuple ImmutableTuple
9998
syn keyword rustTrait Tuple1 Tuple2 Tuple3 Tuple4
10099
syn keyword rustTrait Tuple5 Tuple6 Tuple7 Tuple8
101100
syn keyword rustTrait Tuple9 Tuple10 Tuple11 Tuple12
102-
syn keyword rustTrait ImmutableTuple1 ImmutableTuple2 ImmutableTuple3 ImmutableTuple4
103-
syn keyword rustTrait ImmutableTuple5 ImmutableTuple6 ImmutableTuple7 ImmutableTuple8
104-
syn keyword rustTrait ImmutableTuple9 ImmutableTuple10 ImmutableTuple11 ImmutableTuple12
105101
syn keyword rustTrait ImmutableEqVector ImmutableTotalOrdVector ImmutableCloneableVector
106102
syn keyword rustTrait OwnedVector OwnedCloneableVector OwnedEqVector MutableVector
107103
syn keyword rustTrait Vector VectorVector CloneableVector ImmutableVector

src/libnative/io/process.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: |*c_void| -> T) -> T {
529529
let mut tmps = vec::with_capacity(env.len());
530530

531531
for pair in env.iter() {
532-
let kv = format!("{}={}", pair.first(), pair.second());
532+
let kv = format!("{}={}", *pair.ref0(), *pair.ref1());
533533
tmps.push(kv.to_c_str());
534534
}
535535

@@ -553,7 +553,7 @@ fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: |*mut c_void| -> T) -> T {
553553
let mut blk = ~[];
554554

555555
for pair in env.iter() {
556-
let kv = format!("{}={}", pair.first(), pair.second());
556+
let kv = format!("{}={}", *pair.ref0(), *pair.ref1());
557557
blk.push_all(kv.as_bytes());
558558
blk.push(0);
559559
}

src/librustc/middle/trans/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: &ast::Expr,
599599
const_eval::const_uint(i) => i as uint,
600600
_ => cx.sess.span_bug(count.span, "count must be integral const expression.")
601601
};
602-
let vs = vec::from_elem(n, const_expr(cx, elem, is_local).first());
602+
let vs = vec::from_elem(n, const_expr(cx, elem, is_local).val0());
603603
let v = if vs.iter().any(|vi| val_ty(*vi) != llunitty) {
604604
C_struct(vs, false)
605605
} else {

src/librustc/middle/ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4604,7 +4604,7 @@ pub fn determine_inherited_purity(parent: (ast::Purity, ast::NodeId),
46044604
// purity inferred for it, then check it under its parent's purity.
46054605
// Otherwise, use its own
46064606
match child_sigil {
4607-
ast::BorrowedSigil if child.first() == ast::ImpureFn => parent,
4607+
ast::BorrowedSigil if child.val0() == ast::ImpureFn => parent,
46084608
_ => child
46094609
}
46104610
}

src/libstd/iter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2611,7 +2611,7 @@ mod tests {
26112611
assert_eq!(vi.size_hint(), (10, Some(10)));
26122612

26132613
assert_eq!(c.take(5).size_hint(), (5, Some(5)));
2614-
assert_eq!(c.skip(5).size_hint().second(), None);
2614+
assert_eq!(c.skip(5).size_hint().val1(), None);
26152615
assert_eq!(c.take_while(|_| false).size_hint(), (0, None));
26162616
assert_eq!(c.skip_while(|_| false).size_hint(), (0, None));
26172617
assert_eq!(c.enumerate().size_hint(), (uint::MAX, None));

src/libstd/prelude.rs

-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ pub use io::{Buffer, Writer, Reader, Seek};
6767
pub use str::{Str, StrVector, StrSlice, OwnedStr, IntoMaybeOwned};
6868
pub use to_bytes::IterBytes;
6969
pub use to_str::{ToStr, IntoStr};
70-
pub use tuple::{CloneableTuple, ImmutableTuple};
7170
pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4};
7271
pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8};
7372
pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12};

src/libstd/str.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -567,14 +567,14 @@ impl<'a> Iterator<&'a str> for StrSplits<'a> {
567567
// Helper functions used for Unicode normalization
568568
fn canonical_sort(comb: &mut [(char, u8)]) {
569569
use iter::range;
570-
use tuple::CloneableTuple;
570+
use tuple::Tuple2;
571571

572572
let len = comb.len();
573573
for i in range(0, len) {
574574
let mut swapped = false;
575575
for j in range(1, len-i) {
576-
let classA = comb[j-1].second();
577-
let classB = comb[j].second();
576+
let classA = *comb[j-1].ref1();
577+
let classB = *comb[j].ref1();
578578
if classA != 0 && classB != 0 && classA > classB {
579579
comb.swap(j-1, j);
580580
swapped = true;

src/libstd/tuple.rs

+1-76
Original file line numberDiff line numberDiff line change
@@ -19,66 +19,6 @@ use fmt;
1919
use result::{Ok, Err};
2020
use to_str::ToStr;
2121

22-
/// Method extensions to pairs where both types satisfy the `Clone` bound
23-
pub trait CloneableTuple<T, U> {
24-
/// Return the first element of self
25-
fn first(&self) -> T;
26-
/// Return the second element of self
27-
fn second(&self) -> U;
28-
/// Return the results of swapping the two elements of self
29-
fn swap(&self) -> (U, T);
30-
}
31-
32-
impl<T:Clone,U:Clone> CloneableTuple<T, U> for (T, U) {
33-
/// Return the first element of self
34-
#[inline]
35-
fn first(&self) -> T {
36-
match *self {
37-
(ref t, _) => (*t).clone(),
38-
}
39-
}
40-
41-
/// Return the second element of self
42-
#[inline]
43-
fn second(&self) -> U {
44-
match *self {
45-
(_, ref u) => (*u).clone(),
46-
}
47-
}
48-
49-
/// Return the results of swapping the two elements of self
50-
#[inline]
51-
fn swap(&self) -> (U, T) {
52-
match (*self).clone() {
53-
(t, u) => (u, t),
54-
}
55-
}
56-
}
57-
58-
/// Method extensions for pairs where the types don't necessarily satisfy the
59-
/// `Clone` bound
60-
pub trait ImmutableTuple<T, U> {
61-
/// Return a reference to the first element of self
62-
fn first_ref<'a>(&'a self) -> &'a T;
63-
/// Return a reference to the second element of self
64-
fn second_ref<'a>(&'a self) -> &'a U;
65-
}
66-
67-
impl<T, U> ImmutableTuple<T, U> for (T, U) {
68-
#[inline]
69-
fn first_ref<'a>(&'a self) -> &'a T {
70-
match *self {
71-
(ref t, _) => t,
72-
}
73-
}
74-
#[inline]
75-
fn second_ref<'a>(&'a self) -> &'a U {
76-
match *self {
77-
(_, ref u) => u,
78-
}
79-
}
80-
}
81-
8222
// macro for implementing n-ary tuple functions and operations
8323
macro_rules! tuple_impls {
8424
($(
@@ -339,26 +279,11 @@ mod tests {
339279
use clone::Clone;
340280
use cmp::*;
341281

342-
#[test]
343-
fn test_tuple_ref() {
344-
let x = (~"foo", ~"bar");
345-
assert_eq!(x.first_ref(), &~"foo");
346-
assert_eq!(x.second_ref(), &~"bar");
347-
}
348-
349-
#[test]
350-
fn test_tuple() {
351-
assert_eq!((948, 4039.48).first(), 948);
352-
assert_eq!((34.5, ~"foo").second(), ~"foo");
353-
assert_eq!(('a', 2).swap(), (2, 'a'));
354-
}
355-
356282
#[test]
357283
fn test_clone() {
358284
let a = (1, ~"2");
359285
let b = a.clone();
360-
assert_eq!(a.first(), b.first());
361-
assert_eq!(a.second(), b.second());
286+
assert_eq!(a, b);
362287
}
363288

364289
#[test]

src/test/bench/task-perf-alloc-unwind.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ fn recurse_or_fail(depth: int, st: Option<State>) {
9090
State {
9191
managed: @Cons((), st.managed),
9292
unique: ~Cons((), @*st.unique),
93-
tuple: (@Cons((), st.tuple.first()),
94-
~Cons((), @*st.tuple.second())),
93+
tuple: (@Cons((), st.tuple.ref0().clone()),
94+
~Cons((), @*st.tuple.ref1().clone())),
9595
vec: st.vec + &[@Cons((), *st.vec.last().unwrap())],
9696
res: r(@Cons((), st.res._l))
9797
}

0 commit comments

Comments
 (0)