mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-11 16:15:03 +00:00
stdlib: Rename list::length to list::len to match vec::len
This commit is contained in:
parent
2e8a8390d5
commit
49e8ffa34f
@ -95,11 +95,11 @@ fn has<T>(ls: list<T>, elt: T) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: length
|
Function: len
|
||||||
|
|
||||||
Returns the length of a list
|
Returns the length of a list
|
||||||
*/
|
*/
|
||||||
fn length<T>(ls: list<T>) -> uint {
|
fn len<T>(ls: list<T>) -> uint {
|
||||||
fn count<T>(_t: T, &&u: uint) -> uint { ret u + 1u; }
|
fn count<T>(_t: T, &&u: uint) -> uint { ret u + 1u; }
|
||||||
ret foldl(ls, 0u, bind count(_, _));
|
ret foldl(ls, 0u, bind count(_, _));
|
||||||
}
|
}
|
||||||
|
@ -59,8 +59,8 @@ fn test_has() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_length() {
|
fn test_len() {
|
||||||
let l = from_vec([0, 1, 2]);
|
let l = from_vec([0, 1, 2]);
|
||||||
assert (list::length(l) == 3u);
|
assert (list::len(l) == 3u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user