Great news... I'll admit I have no idea what "unboxed closures" are,
exactly, google wasn't helpful finding out a post clearly describing them.
The example in
http://www.mail-archive.com/[email protected]/msg07569.html shows
passing a closure to a map, so it obviously isn't a call-once so it can't
consume an owned pointer. E.g., if it was `|&x| x +
f(move-some-owned-pointer-from-the-context-to-be-consumed-by-f)`, then it
wouldn't - and shouldn't - work.

But writing something like my_container.modify_value_of_existing_key(key,
|&old| f(old, move-some-owned-pointer-from-context))` should work - I don't
see how both closures can have the same type.


On Tue, Dec 31, 2013 at 4:29 PM, Patrick Walton <[email protected]>wrote:

> On 12/31/13 6:26 AM, Oren Ben-Kiki wrote:
>
>> The point is that sometimes you really *don't* want the closure to be
>> send-able, because you want it to access from the surrounding context
>> both owned pointers (-> be called-once) _and also_ borrowed pointers (->
>> be stack-allocated). This is vital for some use cases and is impossible
>> today (ok, possible by painfully wrapping a cell around each owned
>> pointer and taking its value in the stack closure).
>>
>
> You can do all of that with unboxed closures.
>
> Patrick
>
> _______________________________________________
> Rust-dev mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/rust-dev
>
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to