Skip to content

Commit 61e3c27

Browse files
committed
---
yaml --- r: 149625 b: refs/heads/try2 c: 1c27c90 h: refs/heads/master i: 149623: 54e7f4c v: v3
1 parent 0fff66d commit 61e3c27

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
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 65f19932309f068e09c7472dc06b3e8856afb6fc
8+
refs/heads/try2: 1c27c90119b7e55ce160f39543874b166db7eae6
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

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