Thanks! :D
It compiles now! (and works)
The working code is here:
https://github.com/astrieanna/rust-fun/blob/one_worker_per_element/pmap.rs
Best,
Leah
On Sat, Nov 2, 2013 at 5:21 PM, Simon Sapin wrote:
> Le 02/11/2013 21:05, Leah Hanson a écrit :
>
> Thanks, Brendan. :)
>>
>> You’re
Le 02/11/2013 21:05, Leah Hanson a écrit :
Thanks, Brendan. :)
You’re trying to move the ~strs out of the vector. You’ll need to
use `move_iter`:
Is this "moving" about moving memory around or about promising the
compiler that I won't use those elements of the vector again?
~str is an
Instead of `do spawn` try `do spawn_with(s) |s| { ... }`. Then the closure
won't close over s, but rather take it as an argument, allowing it to move
it out.
Cheers
On Sat, Nov 2, 2013 at 5:05 PM, Leah Hanson wrote:
> Thanks, Brendan. :)
>
> You’re trying to move the ~strs out of the vector. Y
Thanks, Brendan. :)
You’re trying to move the ~strs out of the vector. You’ll need to use
> `move_iter`:
>
Is this "moving" about moving memory around or about promising the compiler
that I won't use those elements of the vector again?
> ~~~
> let ports = do myvect.move_iter().map |s| {
> le
You’re trying to move the ~strs out of the vector. You’ll need to use
`move_iter`:
~~~
let ports = do myvect.move_iter().map |s| {
let (pport, cchan) = stream();
do spawn {
cchan.send(fun(s))
}
pport
}.to_owned_vec();
~~~
Also note the use of `to_owned_vec`. `map` lazily
Thanks, Scott, I think that's closer.
However, now I'm having trouble with my pointer types. Using the element
inside a spawn means that I need to capture the owned string in the right
way so that the compiler allows me to give it to the other task.
This version:
~~~
let ports = do myvect.iter().
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.
I want to end up with a [Port]. (or ~ or @ or whatever. I just want
to be able to iterate over the Ports later.)
S
Hi,
I have a ~[~str]. I have code that will turn a ~str into a Port.
I want to end up with a [Port]. (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.i