]> git.proxmox.com Git - rustc.git/blob - src/doc/book/redirects/const-and-static.md
New upstream version 1.25.0+dfsg1
[rustc.git] / src / doc / book / redirects / const-and-static.md
1 % `const` and `static`
2
3 <small>There is a new edition of the book and this is an old link.</small>
4
5 > Constants are _always_ immutable, and may only be set to a constant expression, not the result of a function call or any other value that could only be computed at runtime.
6 >
7 > Global variables are called `static` in Rust.
8
9 ```rust
10 const MAX_POINTS: u32 = 100_000;
11 static HELLO_WORLD: &str = "Hello, world!";
12 ```
13
14 ---
15
16 Here are the relevant sections in the new and old books:
17
18 * **[In the second edition: Ch 3.01 — Variables and Mutability, section Constants][2]**
19 * **[In the second edition: Ch 19.01 — Unsafe Rust, section Static Variables][3]**
20 * <small>[In the first edition: Ch 3.26 — `const` and `static`][1]</small>
21
22
23 [1]: first-edition/const-and-static.html
24 [2]: second-edition/ch03-01-variables-and-mutability.html#differences-between-variables-and-constants
25 [3]: second-edition/ch19-01-unsafe-rust.html#accessing-or-modifying-a-mutable-static-variable