Skip to content

Commit c0f4976

Browse files
committed
Rollup merge of rust-lang#53231 - GuillaumeGomez:let-keyword, r=QuietMisdreavus
Add let keyword doc Part of rust-lang#34601.
2 parents cbcfa2c + f9f934f commit c0f4976

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

src/libstd/keyword_docs.rs

+31-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -26,3 +26,33 @@
2626
///
2727
/// [book]: https://doc.rust-lang.org/book/second-edition/ch03-03-how-functions-work.html
2828
mod fn_keyword { }
29+
30+
#[doc(keyword = "let")]
31+
//
32+
/// The `let` keyword.
33+
///
34+
/// The `let` keyword is used to declare a variable.
35+
///
36+
/// Example:
37+
///
38+
/// ```rust
39+
/// # #![allow(unused_assignments)]
40+
/// let x = 3; // We create a variable named `x` with the value `3`.
41+
/// ```
42+
///
43+
/// By default, all variables are **not** mutable. If you want a mutable variable,
44+
/// you'll have to use the `mut` keyword.
45+
///
46+
/// Example:
47+
///
48+
/// ```rust
49+
/// # #![allow(unused_assignments)]
50+
/// let mut x = 3; // We create a mutable variable named `x` with the value `3`.
51+
///
52+
/// x += 4; // `x` is now equal to `7`.
53+
/// ```
54+
///
55+
/// For more information about the `let` keyword, take a look at the [Rust Book][book].
56+
///
57+
/// [book]: https://doc.rust-lang.org/book/second-edition/ch03-01-variables-and-mutability.html
58+
mod let_keyword { }

0 commit comments

Comments
 (0)