Skip to content

Commit d918f02

Browse files
authored
Explain that references to static mutable reference is discouraged
1 parent aa8ec31 commit d918f02

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/peripherals/singletons.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn main() {
2323

2424
But this has a few problems. It is a mutable global variable, and in Rust, these are always unsafe to interact with. These variables are also visible across your whole program, which means the borrow checker is unable to help you track references and ownership of these variables.
2525

26-
Up until Rust 2024, the usage of static **mutable** variable has been discouraged. Since Rust 2024, static mutable variable results in an error. Of course, there are legitimate use case of having a shared mutable state, it's just that Rust want you to really think about the scope of the mutability. We'll talk about this later when we talk about interior mutability.
26+
Since Rust 2024, references to static mutable variables are lint-denied by default. Of course, there are legitimate use case of having a shared mutable state, it's just that Rust want you to really think about the scope of the mutability. We'll talk about this later when we talk about interior mutability.
2727

2828
## How do we do this in Rust?
2929

0 commit comments

Comments
 (0)