Thanks for the explanation. Of course, the point is that you'd meed two
types, `OnceFn` which is stack-allocated (non-send-able, can take borrowed
pointers from its context) and `SendFn` which is heap-allocated (send-able,
can't take borrowed pointers from its context). Both would be able to
consume an owned pointer.

I guess we'll see how this ends up when it evolves past being a sketch of
an idea :-)


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

> On 12/31/13 6:39 AM, Oren Ben-Kiki wrote:
>
>> 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.
>>
>
> Presumably along with `Fn<T,U>` there will be something like `OnceFn<T,U>`:
>
>     trait OnceFn<Ret,Args...> {
>         fn call(self, args: Args) -> Ret;
>         //      ^^^^ note by-value self; this is what makes it one-shot
>     }
>
> Note: This is just a strawman sketch of the idea; it may well not work, no
> promises, etc.
>
> Patrick
>
>
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to