I would think:
let ports = do myvect.iter().map { |e| something(e) }On Sat, 2 Nov 2013, Leah Hanson wrote:
Hi, I have a ~[~str]. I have code that will turn a ~str into a Port<uint>. I want to end up with a [Port<uint>]. (or ~ or @ or whatever. I just want to be able to iterate over the Ports later.) Since I'm not sure what looping construct to use, I tried with a for-each loop. ~~~ let ports = for s in myvect.iter() { let (pport, cchan) = stream(); do spawn { cchan.send(fun(*s)) } pport }; ~~~ As you might, expect I got an error: error: mismatched types: expected `()` but found `std::comm::Port<uint>` (expected () but found struct std::comm::Port)From this, I take it that for loops must return `()`, rather than an actualvalue. When I searched for a map function in the documentation, I only found a Map type. How would you map one vector to a vector of a different element type? Thanks, Leah
-- Scott Lawrence _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
