[rust-dev] bikeshed on closure syntax

Patrick Walton pwalton at mozilla.com
Wed Apr 18 17:09:24 PDT 2012


On 4/18/12 5:07 PM, Jeff Schultz wrote:
> Any reason we can't just have an empty '||' instead of the '->'?
>
> It's easier to type and makes it easier to find all closures.

|| looks a little like line noise to me, although I'm not wedded to the 
thin arrow.

     spawn(): -> {
         log("Hi!");
     }

vs.

     spawn(): || {
         log("Hi!");
     }

>
>
>> 3. In any function call, trailing closure arguments can be pulled out and
>> placed after a colon. If this is done, the semicolon statement separator
>> after the call can be omitted.
>
> Why is the ':' needed?

To disambiguate a block from bitwise or.

Patrick


More information about the Rust-dev mailing list