summaryrefslogtreecommitdiffstats
path: root/src/doc/book/redirects/const-and-static.md
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/doc/book/redirects/const-and-static.md
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/doc/book/redirects/const-and-static.md')
-rw-r--r--src/doc/book/redirects/const-and-static.md21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/doc/book/redirects/const-and-static.md b/src/doc/book/redirects/const-and-static.md
new file mode 100644
index 000000000..b87bdd383
--- /dev/null
+++ b/src/doc/book/redirects/const-and-static.md
@@ -0,0 +1,21 @@
+% `const` and `static`
+
+<small>There is a new edition of the book and this is an old link.</small>
+
+> 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.
+>
+> Global variables are called `static` in Rust.
+
+```rust
+const MAX_POINTS: u32 = 100_000;
+static HELLO_WORLD: &str = "Hello, world!";
+```
+
+---
+
+You can find the latest version about constants
+[here](ch03-01-variables-and-mutability.html#constants),
+and about statics
+[here](ch19-01-unsafe-rust.html#accessing-or-modifying-a-mutable-static-variable).
+
+