Skip to content

Commit f18cb40

Browse files
committed
test mutating a non-mut static with interior mutability
1 parent ca698a6 commit f18cb40

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
use std::sync::atomic::{Ordering, AtomicUsize};
2+
13
static mut X: usize = 5;
4+
static Y: AtomicUsize = AtomicUsize::new(5);
25

36
fn main() {
47
unsafe {
58
X = 6;
69
assert_eq!(X, 6);
710
}
11+
12+
Y.store(6, Ordering::Relaxed);
13+
assert_eq!(Y.load(Ordering::Relaxed), 6);
814
}

0 commit comments

Comments
 (0)