I wonder if the idea of using ref by default in patterns for Copyless
types has being considered? The need to move on pattern match should
be infrequent. So it is better to use a special syntax for that case
skipping box ref and similar in most of the code.

On 28 May 2014 06:23, Corey Richardson <[email protected]> wrote:
> As with most things in Rust, in a pattern, a keyword means the
> *opposite* of its normal meaning. So where `box e` in an expression
> will box up the result of `e`, `box p` in a pattern will unbox `p`.
>
> On Tue, May 27, 2014 at 9:50 AM, Tommi <[email protected]> wrote:
>> What is the meaning of this 'box ref foo' syntax found in the tutorial over 
>> at http://doc.rust-lang.org/tutorial.html#references
>>
>> In short, it's:
>>
>> enum Shape { Sphere(Box<f32>) }
>>
>> let shape = Sphere(box 1.0f32);
>> let r = match shape {
>>     Sphere(box ref radius) => *radius
>> };
>>
>> I thought the 'box' keyword meant: "allocate on heap and wrap into a Box". 
>> That doesn't make sense to me in the context of 'box ref radius'.
>>
>> _______________________________________________
>> Rust-dev mailing list
>> [email protected]
>> https://mail.mozilla.org/listinfo/rust-dev
>
>
>
> --
> http://octayn.net/
> _______________________________________________
> 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