[rust-dev] RFC: Future-proof for unboxed closures

Gábor Lehel glaebhoerl at gmail.com
Mon Jan 27 11:33:57 PST 2014


On Mon, Jan 27, 2014 at 12:03 PM, Niko Matsakis <niko at alum.mit.edu> wrote:

> On Sat, Jan 25, 2014 at 07:07:32PM +0100, Gábor Lehel wrote:
> > If you wanted to pass an unboxed closure without indirection though, like
> > `fn foo<T: Fn<U, R>>(x: T)`, then you would have to explicitly
> dereference
> > the closure, i.e. `foo(*|u| r)` (which might be OK).
>
> Why would you want to do that? There is no advantage to doing so; the ABI
> will almost certainly reintroduce indirection anyhow.
>

I think this question has a more general form, namely: when should I pass
by value and when using &move/&my? I expect this will come up quite a bit
if we add the latter.


>
> > The basic problem is that there's a zoo of closure types:
> > http://glaebhoerl.tumblr.com/rust_closure_types (I will be referring to
> > things from this in the following!)
>
> No time to write a long response here just now, but this is a very
> nice writeup, thanks.
>
>
>
> Niko
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140127/58864234/attachment.html>


More information about the Rust-dev mailing list