rust/src/test/run-pass/iter-map-to-vec.rs

10 lines
296 B
Rust

fn inc(&&x: uint) -> uint { x + 1u }
fn main() {
assert [1u, 3u]/_.map_to_vec(inc) == ~[2u, 4u];
assert [1u, 2u, 3u]/_.map_to_vec(inc) == ~[2u, 3u, 4u];
assert none.map_to_vec(inc) == ~[];
assert some(1u).map_to_vec(inc) == ~[2u];
assert some(2u).map_to_vec(inc) == ~[3u];
}