[rust-dev] "let mut" <-> "var"

Patrick Walton pcwalton at mozilla.com
Wed Jan 29 18:35:53 PST 2014

On 1/29/14 6:34 PM, Samuel Williams wrote:
> Perhaps this has been considered already, but when I'm reading rust code
> "let mut" just seems to stick out all over the place. Why not add a
> "var" keyword that does the same thing? I think there are lots of good
> and bad reasons to do this or not do it, but I just wanted to propose
> the idea and see what other people are thinking.

`let` takes a pattern. `mut` is a modifier on variables in a pattern. It 
is reasonable to write `let (x, mut y) = ...`, `let (mut x, y) = ...`, 
`let (mut x, mut y) = ...`, and so forth.

Having a special "var" syntax would defeat this orthogonality.


More information about the Rust-dev mailing list