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 actual
value. 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
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to