1
Fork 0

doc: improve/fix 'let' FAQ

This commit is contained in:
Tshepang Lekhonkhobe 2015-04-18 17:36:41 +02:00
parent 3b2530c748
commit 4665c3bbfa

View file

@ -165,12 +165,13 @@ particularly easy to read.
## Why is `let` used to introduce variables? ## Why is `let` used to introduce variables?
We don't use the term "variable", instead, we use "variable bindings". The Instead of the term "variable", we use "variable bindings". The
simplest way for binding is the `let` syntax, other ways including `if let`, simplest way for creating a binding is by using the `let` syntax.
`while let` and `match`. Bindings also exist in function arguments positions. Other ways include `if let`, `while let`, and `match`. Bindings also
exist in function argument positions.
Bindings always happen in pattern matching positions, and it's also Rust's way Bindings always happen in pattern matching positions, and it's also Rust's way
to declare mutability. One can also redeclare mutability of a binding in to declare mutability. One can also re-declare mutability of a binding in
pattern matching. This is useful to avoid unnecessary `mut` annotations. An pattern matching. This is useful to avoid unnecessary `mut` annotations. An
interesting historical note is that Rust comes, syntactically, most closely interesting historical note is that Rust comes, syntactically, most closely
from ML, which also uses `let` to introduce bindings. from ML, which also uses `let` to introduce bindings.