diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-09-04 15:46:19 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-09-04 15:46:34 -0700 |
| commit | ef880f22450c4f7e455f431ff4603f90d443b545 (patch) | |
| tree | 6de9f9d0013ff105137bac75d19890fb670f79d9 /doc | |
| parent | 02b1c32e4d3c607da8b3a48640e597f089375765 (diff) | |
| download | rust-ef880f22450c4f7e455f431ff4603f90d443b545.tar.gz rust-ef880f22450c4f7e455f431ff4603f90d443b545.zip | |
doc: Fix broken examples
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/rust.md | 12 |
1 files changed, 6 insertions, 6 deletions
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<T>(ls: list<T>) -> uint { /* ... */ } +pure fn pure_length<T>(ls: List<T>) -> uint { /* ... */ } -pure fn nonempty_list<T>(ls: list<T>) -> bool { pure_length(ls) > 0u } +pure fn nonempty_list<T>(ls: List<T>) -> 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<T, U: copy>(ls: list<T>, u: U, f: fn(&&T, &&U) -> U) -> U { +fn pure_foldl<T, U: copy>(ls: List<T>, 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<T>(ls: list<T>) -> uint { +pure fn pure_length<T>(ls: List<T>) -> uint { fn count<T>(_t: T, &&u: uint) -> uint { u + 1u } unchecked { pure_foldl(ls, 0u, count) |
