stdlib: make list::from_vec take [mutable? T]
This commit is contained in:
parent
83219269d5
commit
d53a253dca
2 changed files with 9 additions and 1 deletions
|
|
@ -25,7 +25,7 @@ Function: from_vec
|
|||
|
||||
Create a list from a vector
|
||||
*/
|
||||
fn from_vec<T>(v: [T]) -> list<T> {
|
||||
fn from_vec<T>(v: [mutable? T]) -> list<T> {
|
||||
let l = nil::<T>;
|
||||
// FIXME: This would be faster and more space efficient if it looped over
|
||||
// a reverse vector iterator. Unfortunately generic iterators seem not to
|
||||
|
|
|
|||
|
|
@ -14,6 +14,14 @@ fn test_from_vec() {
|
|||
assert (car(cdr(cdr(l))) == 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_from_vec_mut() {
|
||||
let l = from_vec([mutable 0, 1, 2]);
|
||||
assert (car(l) == 0);
|
||||
assert (car(cdr(l)) == 1);
|
||||
assert (car(cdr(cdr(l))) == 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_foldl() {
|
||||
let l = from_vec([0, 1, 2, 3, 4]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue