Skip to content

Commit 141a94f

Browse files
committed
---
yaml --- r: 106485 b: refs/heads/try c: 1c27c90 h: refs/heads/master i: 106483: 205a686 v: v3
1 parent 8d2f8b7 commit 141a94f

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
@@ -2,7 +2,7 @@
22
refs/heads/master: b8ef9fd9c9f642ce7b8aed82782a1ed745d08d64
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: b8601a3d8b91ad3b653d143307611f2f5c75617e
5-
refs/heads/try: 65f19932309f068e09c7472dc06b3e8856afb6fc
5+
refs/heads/try: 1c27c90119b7e55ce160f39543874b166db7eae6
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/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)