You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to help out @ben0x539 with some code of his: https://gist.github.com/3846368. He's messing around with moving a channel into a task, which is then passed to a closure. This fails with
foo.rs:5:56: 5:58 error: copying a noncopyable value
foo.rs:5 let fail_: fn~(~str) -> ! = fn~(x: ~str) -> ! { wr.send(x); fail; };
^~
foo.rs:5:56: 5:58 note: non-copyable value cannot be copied into a ~fn closure
foo.rs:5 let fail_: fn~(~str) -> ! = fn~(x: ~str) -> ! { wr.send(x); fail; };
However, if we get rid of the task, it works fine. I would have thought that moving the channel into the task would be roughly equivalent to the non-task version, but I'm probably missing some subtly in the borrower.
In the meantime, you can use pipes::SharedChan to write this kind of function.
The text was updated successfully, but these errors were encountered:
This is a dup of #2549. Basically the problem here is that you cannot move out of upvars right now, because Rust function types always assume they may be called more than once. To work around this, you must either use a channel to send the value to the task (rather than capturing it via an upvar) or use the so-called "option dance". Hopefully this will be fixed in 0.5.
I was trying to help out @ben0x539 with some code of his: https://gist.github.com/3846368. He's messing around with moving a channel into a task, which is then passed to a closure. This fails with
However, if we get rid of the task, it works fine. I would have thought that moving the channel into the task would be roughly equivalent to the non-task version, but I'm probably missing some subtly in the borrower.
In the meantime, you can use
pipes::SharedChan
to write this kind of function.The text was updated successfully, but these errors were encountered: