test mutating a non-mut static with interior mutability
This commit is contained in:
parent
ca698a6eac
commit
f18cb40e4c
1 changed files with 6 additions and 0 deletions
|
|
@ -1,8 +1,14 @@
|
|||
use std::sync::atomic::{Ordering, AtomicUsize};
|
||||
|
||||
static mut X: usize = 5;
|
||||
static Y: AtomicUsize = AtomicUsize::new(5);
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
X = 6;
|
||||
assert_eq!(X, 6);
|
||||
}
|
||||
|
||||
Y.store(6, Ordering::Relaxed);
|
||||
assert_eq!(Y.load(Ordering::Relaxed), 6);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue