@@ -163,13 +163,17 @@ This is to make the language easier to parse for humans, especially in the face
163
163
of higher-order functions. ` fn foo<T>(f: fn(int): int, fn(T): U): U ` is not
164
164
particularly easy to read.
165
165
166
- ## ` let ` is used to introduce variables
166
+ ## Why is ` let ` used to introduce variables?
167
167
168
- ` let ` not only defines variables, but can do pattern matching. One can also
169
- redeclare immutable variables with ` let ` . This is useful to avoid unnecessary
170
- ` mut ` annotations. An interesting historical note is that Rust comes,
171
- syntactically, most closely from ML, which also uses ` let ` to introduce
172
- bindings.
168
+ We don't use the term "variable", instead, we use "variable bindings". The
169
+ simplest way for binding is the ` let ` syntax, other ways including ` if let ` ,
170
+ ` while let ` and ` match ` . Bindings also exist in function arguments positions.
171
+
172
+ Bindings always happen in pattern matching positions, and it's also Rust's way
173
+ to declare mutability. One can also redeclare mutability of a binding in
174
+ pattern matching. This is useful to avoid unnecessary ` mut ` annotations. An
175
+ interesting historical note is that Rust comes, syntactically, most closely
176
+ from ML, which also uses ` let ` to introduce bindings.
173
177
174
178
See also [ a long thread] [ alt ] on renaming ` let mut ` to ` var ` .
175
179
0 commit comments