diff --git a/doc/rust.md b/doc/rust.md index 9023147208c..4a654703404 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -1027,9 +1027,9 @@ pure fn lt_42(x: int) -> bool { Pure functions may call other pure functions: ~~~~{.xfail-test} -pure fn pure_length(ls: list) -> uint { /* ... */ } +pure fn pure_length(ls: List) -> uint { /* ... */ } -pure fn nonempty_list(ls: list) -> bool { pure_length(ls) > 0u } +pure fn nonempty_list(ls: List) -> bool { pure_length(ls) > 0u } ~~~~ *TODO:* should actually define referential transparency. @@ -1055,14 +1055,14 @@ An example of a pure function that uses an unchecked block: ~~~~ # import std::list::*; -fn pure_foldl(ls: list, u: U, f: fn(&&T, &&U) -> U) -> U { +fn pure_foldl(ls: List, u: U, f: fn(&&T, &&U) -> U) -> U { match ls { - nil => u, - cons(hd, tl) => f(hd, pure_foldl(*tl, f(hd, u), f)) + Nil => u, + Cons(hd, tl) => f(hd, pure_foldl(*tl, f(hd, u), f)) } } -pure fn pure_length(ls: list) -> uint { +pure fn pure_length(ls: List) -> uint { fn count(_t: T, &&u: uint) -> uint { u + 1u } unchecked { pure_foldl(ls, 0u, count)