@@ -19,66 +19,6 @@ use fmt;
19
19
use result:: { Ok , Err } ;
20
20
use to_str:: ToStr ;
21
21
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
-
82
22
// macro for implementing n-ary tuple functions and operations
83
23
macro_rules! tuple_impls {
84
24
( $(
@@ -339,26 +279,11 @@ mod tests {
339
279
use clone:: Clone ;
340
280
use cmp:: * ;
341
281
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
-
356
282
#[ test]
357
283
fn test_clone ( ) {
358
284
let a = ( 1 , ~"2 ") ;
359
285
let b = a. clone ( ) ;
360
- assert_eq!(a.first(), b.first());
361
- assert_eq!(a.second(), b.second());
286
+ assert_eq ! ( a, b) ;
362
287
}
363
288
364
289
#[ test]
0 commit comments