2018-09-23 09:14:55 +02:00
|
|
|
use std::sync::atomic::{Ordering, AtomicUsize};
|
|
|
|
|
2016-06-02 17:05:17 +02:00
|
|
|
static mut X: usize = 5;
|
2018-09-23 09:14:55 +02:00
|
|
|
static Y: AtomicUsize = AtomicUsize::new(5);
|
2016-06-02 17:05:17 +02:00
|
|
|
|
2016-06-13 14:27:05 +02:00
|
|
|
fn main() {
|
2016-06-02 17:05:17 +02:00
|
|
|
unsafe {
|
|
|
|
X = 6;
|
|
|
|
assert_eq!(X, 6);
|
|
|
|
}
|
2018-09-23 09:14:55 +02:00
|
|
|
|
|
|
|
Y.store(6, Ordering::Relaxed);
|
|
|
|
assert_eq!(Y.load(Ordering::Relaxed), 6);
|
2016-06-02 17:05:17 +02:00
|
|
|
}
|