This doesn't seems to work for me (rust-0.10)
let x : ~[uint] = ~[1,2,3];
let sieved: ~[uint] = x.iter().filter(|&n| 3 % n == 0).collect();
...
prob0003.rs:49:77: 49:78 error: mismatched types: expected `<generic integer #5>` but found `&uint` (expected &-ptr but found integral variable)
prob0003.rs:49 let x : ~[uint] = ~[1,2,3]; let sieved: ~[uint] = x.iter().filter(|&n| 3 % n == 0).collect();
The problem is in your collect() call. The iterator is over &uint, and so collect() would expect to produce something like ~[&uint].
You should change it to use move_iter() instead of iter(), or else put in a .map(|&n| n).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With