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