-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
var as alias for let mut #2402
Comments
Hi there; and thank you for your interest in Rust language design! To file a formal proposal, you should follow the guide here: https://github.com/rust-lang/rfcs#what-the-process-is But before doing so, it is best to file a pre-RFC on https://internals.rust-lang.org/ However, in this case, we previously discussed this at #2304. |
@Centril I think it should be highly considered. Making every Rust variable declaration immutable by default would greatly affect its adoption rate, it greatly reduces productivity in my opinion. I am certain that having both options( |
@Centril I still believe in providing this option. Clippy can add an option to disable this keyword programmers believe it can lead to confusion. In addition to compiler warning in case it's not needed similar to |
@medozs I hear you; but the best place to discuss a proposal that hasn't fully baked is over at https://internals.rust-lang.org/. Furthermore, please avoid closing and reopening the same issue several times =) |
Hello Everyone,
I propose rust to implement
var
keyword as an alias forlet mut
. Some might think that's unnecessary and I respect that, however, I think people who would like to create mutable variables by default without much cognitive thinking deserve that option too.It would also make rust similar to 99% of language out there that has var being the default for mutable variables.
This is similar to the optional keyword
return
found in rust, where you don't have to use it, but it's available if you would like to.The compiler can suggest to turn
var
intolet
if it's not necessary.It would make rust more natural as a programming language similar to most languages.
It's doesn't have to be named
var
, you can pick another to allow the function.You might say that having
let
andvar
would make it confusing; however, Rust already has a similar situation with theconst
andlet
keywords, where both function as an immutable variable but they are implemented differently.The
var
keyword can be denied by clippy as well if you would like too.Thank you,
The text was updated successfully, but these errors were encountered: