Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ce80c9f

Browse filesBrowse files
authored
Rollup merge of rust-lang#133145 - kornelski:static-mutex, r=traviscross
Document alternatives to `static mut` In rust-lang#133143 I've noticed alternatives to `static mut` aren't documented anywhere.
2 parents 86151ab + 15e6fc0 commit ce80c9f
Copy full SHA for ce80c9f

File tree

Expand file treeCollapse file tree

1 file changed

+6
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-0
lines changed

‎std/src/keyword_docs.rs

Copy file name to clipboardExpand all lines: std/src/keyword_docs.rs
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,6 +1448,9 @@ mod self_upper_keyword {}
14481448
/// in a multithreaded context. As such, all accesses to mutable `static`s
14491449
/// require an [`unsafe`] block.
14501450
///
1451+
/// When possible, it's often better to use a non-mutable `static` with an
1452+
/// interior mutable type such as [`Mutex`], [`OnceLock`], or an [atomic].
1453+
///
14511454
/// Despite their unsafety, mutable `static`s are necessary in many contexts:
14521455
/// they can be used to represent global state shared by the whole program or in
14531456
/// [`extern`] blocks to bind to variables from C libraries.
@@ -1468,7 +1471,10 @@ mod self_upper_keyword {}
14681471
/// [`extern`]: keyword.extern.html
14691472
/// [`mut`]: keyword.mut.html
14701473
/// [`unsafe`]: keyword.unsafe.html
1474+
/// [`Mutex`]: sync::Mutex
1475+
/// [`OnceLock`]: sync::OnceLock
14711476
/// [`RefCell`]: cell::RefCell
1477+
/// [atomic]: sync::atomic
14721478
/// [Reference]: ../reference/items/static-items.html
14731479
mod static_keyword {}
14741480

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.