From d7fcf8216a03e5256a1649b22b3927e8a12bd503 Mon Sep 17 00:00:00 2001 From: Andrew Walbran Date: Tue, 17 Jan 2023 16:21:02 +0000 Subject: [PATCH] Mutable statics are generally a bad idea. --- src/unsafe/mutable-static-variables.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/unsafe/mutable-static-variables.md b/src/unsafe/mutable-static-variables.md index 2560bd54..80f60d15 100644 --- a/src/unsafe/mutable-static-variables.md +++ b/src/unsafe/mutable-static-variables.md @@ -26,3 +26,10 @@ fn main() { unsafe { println!("COUNTER: {}", COUNTER); } // Potential data race! } ``` + +
+ +Using a mutable static is generally a bad idea, but there are some cases where it might make sense +in low-level `no_std` code, such as implementing a heap allocator or working with some C APIs. + +