Skip to content

Commit c03719e

Browse files
authored
Reorganize statics and mention external statics
1 parent 60386ff commit c03719e

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/items/static-items.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88
A *static item* is similar to a [constant], except that it represents a precise
99
memory location in the program. All references to the static refer to the same
1010
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.
1413

15-
All access to an immutable 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 an non-`mut` static is safe, but there are a number of restrictions:
1720

1821
* The type must have the `Sync` trait bound to allow thread-safe access.
1922
* Statics allow using paths to statics in the [constant expression] used to
@@ -71,6 +74,7 @@ following are true:
7174
[constant]: constant-items.md
7275
[`drop`]: ../destructors.md
7376
[constant expression]: ../const_eval.md#constant-expressions
77+
[external statics]: external-blocks#statics
7478
[interior mutable]: ../interior-mutability.md
7579
[IDENTIFIER]: ../identifiers.md
7680
[_Type_]: ../types.md#type-expressions

0 commit comments

Comments
 (0)