Skip to content

Commit d53a253

Browse files
committed
stdlib: make list::from_vec take [mutable? T]
1 parent 8321926 commit d53a253

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/lib/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Function: from_vec
2525
2626
Create a list from a vector
2727
*/
28-
fn from_vec<T>(v: [T]) -> list<T> {
28+
fn from_vec<T>(v: [mutable? T]) -> list<T> {
2929
let l = nil::<T>;
3030
// FIXME: This would be faster and more space efficient if it looped over
3131
// a reverse vector iterator. Unfortunately generic iterators seem not to

src/test/stdtest/list.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ fn test_from_vec() {
1414
assert (car(cdr(cdr(l))) == 2);
1515
}
1616

17+
#[test]
18+
fn test_from_vec_mut() {
19+
let l = from_vec([mutable 0, 1, 2]);
20+
assert (car(l) == 0);
21+
assert (car(cdr(l)) == 1);
22+
assert (car(cdr(cdr(l))) == 2);
23+
}
24+
1725
#[test]
1826
fn test_foldl() {
1927
let l = from_vec([0, 1, 2, 3, 4]);

0 commit comments

Comments
 (0)