Skip to content

Commit 453edde

Browse files
committed
Update 'let is used to introduce variables' paragraph
1 parent cf51e55 commit 453edde

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/doc/complement-design-faq.md

+11-7
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,17 @@ This is to make the language easier to parse for humans, especially in the face
163163
of higher-order functions. `fn foo<T>(f: fn(int): int, fn(T): U): U` is not
164164
particularly easy to read.
165165

166-
## `let` is used to introduce variables
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.
166+
## How to introduce variables?
167+
168+
We don't use the term variable, instead we use bindings.
169+
The simplest way for binding is the `let` syntax, other ways including
170+
`if let`, `while let` and `match`. Bindings also exist in function arguments
171+
positions.
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 pattern
174+
matching. This is useful to avoid unnecessary `mut` annotations. An interesting
175+
historical note is that Rust comes, syntactically, most closely from ML, which
176+
also uses `let` to introduce bindings.
173177

174178
See also [a long thread][alt] on renaming `let mut` to `var`.
175179

0 commit comments

Comments
 (0)