You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the introduction to variables (https://doc.rust-lang.org/nightly/reference/variables.html#r-variable.intro) 'named local variables' are introduced. From that point on the text only refers to 'local variables'. I am left with some doubt whether they are referring to the same thing. I only found the phrase 'named local variables' once. Of course, a named local variable is a local variable, but are there unnamed local variables? They would need to be different to anonymous temporaries which are explicitly listed in the first paragraph.
If my understanding is correct, I think it would be clearer if the first paragraph did not use the word 'named' and just called them 'local variable' (and 'function parameter' now I am looking at it). You could then follow it up with a statement such as 'All local variables are provided names through a let statement', and something similar for function parameters.
It feels that there is also room to explicitly state what happens with something like let _ = ...... Does this introduce a variable? I don't know the definitive answer there, but the wildcard pattern says that it does not copy, move, or borrow. So if a variable was introduced it would remain in an uninitialized state despite having an initializer. So I think that this cannot be a variable and eliminates my front-runner for what an unnamed variable looked like!
The text was updated successfully, but these errors were encountered:
ehuss
added
the
Language Cleanup
Improvements to existing language which is correct but not clear, or missing examples, or the like.
label
May 20, 2025
In the introduction to variables (https://doc.rust-lang.org/nightly/reference/variables.html#r-variable.intro) 'named local variables' are introduced. From that point on the text only refers to 'local variables'. I am left with some doubt whether they are referring to the same thing. I only found the phrase 'named local variables' once. Of course, a named local variable is a local variable, but are there unnamed local variables? They would need to be different to anonymous temporaries which are explicitly listed in the first paragraph.
If my understanding is correct, I think it would be clearer if the first paragraph did not use the word 'named' and just called them 'local variable' (and 'function parameter' now I am looking at it). You could then follow it up with a statement such as 'All local variables are provided names through a let statement', and something similar for function parameters.
It feels that there is also room to explicitly state what happens with something like
let _ = .....
. Does this introduce a variable? I don't know the definitive answer there, but the wildcard pattern says that it does not copy, move, or borrow. So if a variable was introduced it would remain in an uninitialized state despite having an initializer. So I think that this cannot be a variable and eliminates my front-runner for what an unnamed variable looked like!The text was updated successfully, but these errors were encountered: