>
> One argument in favor of John's proposal is that:
>>
>>     let mut foo = 1,
>>         bar = 2;
>>
>> somewhat deceptively declares bar as mutable. However, a lint pass for
>> never-mutated mutable variables (which we'd want anyway) would catch this.
>>
>
> For what it's worth, when I was implementing `let mut` I did a straw
> poll at the time whether
>
>      let mut a = 1, b = 2;
>
> should declare both a and b as mutable or only a, and the response at
> the time was uniformly in favor of "both a and b" (which surprised me,
> since I had intended to do the opposite).
>
> Niko


It seems to me that if you're going to spread the declaration across two
lines, you might as well make it two statements, which would remove
ambiguity here.

    let mut foo = 1;
    let bar = 2;

In the case where both declarations are on the same line, I agree with the
results of Niko's straw poll.

    let mut foo = 1, bar = 2;

This should make both foo and bar be mut, in my opinion.

Chad
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to