|
8 | 8 | A *static item* is similar to a [constant], except that it represents a precise |
9 | 9 | memory location in the program. All references to the static refer to the same |
10 | 10 | memory location. Static items have the `static` lifetime, which outlives all |
11 | | -other lifetimes in a Rust program. Non-`mut` static items that contain a type |
12 | | -that is not [interior mutable] may be placed in read-only memory. Static items |
13 | | -do not call [`drop`] at the end of the program. |
| 11 | +other lifetimes in a Rust program. Static items do not call [`drop`] at the end |
| 12 | +of the program. Note that [external statics] have additional restrictions. |
14 | 13 |
|
15 | | -All access to a static is safe, but there are a number of restrictions on |
16 | | -statics: |
| 14 | +## Non-`mut` statics |
| 15 | + |
| 16 | +Non-`mut` static items that contain a type |
| 17 | +that is not [interior mutable] may be placed in read-only memory. |
| 18 | + |
| 19 | +All access to a non-`mut` static is safe, but there are a number of restrictions: |
17 | 20 |
|
18 | 21 | * The type must have the `Sync` trait bound to allow thread-safe access. |
19 | 22 | * Statics allow using paths to statics in the [constant expression] used to |
@@ -71,6 +74,7 @@ following are true: |
71 | 74 | [constant]: constant-items.md |
72 | 75 | [`drop`]: ../destructors.md |
73 | 76 | [constant expression]: ../const_eval.md#constant-expressions |
| 77 | +[external statics]: external-blocks.md#statics |
74 | 78 | [interior mutable]: ../interior-mutability.md |
75 | 79 | [IDENTIFIER]: ../identifiers.md |
76 | 80 | [_Type_]: ../types.md#type-expressions |
|
0 commit comments