Skip to content

Commit 6b83374

Browse files
committed
---
yaml --- r: 102239 b: refs/heads/master c: 1c27c90 h: refs/heads/master i: 102237: 7745a1a 102235: fe919f2 102231: 7c6e0cf 102223: c79cc7e 102207: ab3d9f6 v: v3
1 parent 518edf0 commit 6b83374

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 65f19932309f068e09c7472dc06b3e8856afb6fc
2+
refs/heads/master: 1c27c90119b7e55ce160f39543874b166db7eae6
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6e7f170fedd3c526a643c0b2d13863acd982be02
55
refs/heads/try: a97642026c18a624ff6ea01075dd9550f8ed07ff

trunk/src/libcollections/list.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,6 @@ impl<T:Eq> List<T> {
8686
}
8787
}
8888

89-
/// Appends one list to another
90-
pub fn append<T:Clone + 'static>(list: @List<T>, other: @List<T>) -> @List<T> {
91-
match *list {
92-
Nil => return other,
93-
Cons(ref head, tail) => {
94-
let rest = append(tail, other);
95-
return @Cons((*head).clone(), rest);
96-
}
97-
}
98-
}
99-
10089
impl<T:'static + Clone> List<T> {
10190
/// Create a list from a vector
10291
pub fn from_vec(v: &[T]) -> List<T> {
@@ -105,6 +94,17 @@ impl<T:'static + Clone> List<T> {
10594
_ => v.rev_iter().fold(Nil, |tail, value: &T| Cons(value.clone(), @tail))
10695
}
10796
}
97+
98+
/// Appends one list to another, returning a new list
99+
pub fn append(&self, other: List<T>) -> List<T> {
100+
match other {
101+
Nil => return self.clone(),
102+
_ => match *self {
103+
Nil => return other,
104+
Cons(ref value, tail) => Cons(value.clone(), @tail.append(other))
105+
}
106+
}
107+
}
108108
}
109109

110110
/*
@@ -225,7 +225,7 @@ mod tests {
225225

226226
#[test]
227227
fn test_append() {
228-
assert!(@List::from_vec([1,2,3,4])
229-
== list::append(@List::from_vec([1,2]), @List::from_vec([3,4])));
228+
assert_eq!(List::from_vec([1, 2, 3, 4]),
229+
List::from_vec([1, 2]).append(List::from_vec([3, 4])));
230230
}
231231
}

0 commit comments

Comments
 (0)