On Sat, 2013-11-30 at 09:34 +0200, Oren Ben-Kiki wrote:

> This is a lose-lose situation. If the container takes a `proc`, then
> Rust complains that it can't capture the non-send-able variable. But
> if the container takes a stack closure, then Rust complains it can't
> use the owned variable. Of course, the container will _not_ send the
> action and will also _not_ call it twice, but it can't express this in
> the action type :-) The only workaround I found is to use a closure
> and wrap each and every non-send-able variable in a cell - this is an
> pointless and downright annoying manual boilerplate code.

I think another previously mentioned workaround is to change all your
closure-taking functions to have a name ending in "_with" and take an
extra generic parameter by value that is then passed to the closure. In
practice, that might end up being a tuple with all the values you're
need to move into and from within the closure.

It's not ideal and requires cooperation from the API but it probably
reads better than a bunch of cells. :)

-benh

_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to