1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
fn basic_raw() { let mut x = 12; let x = &mut x; assert_eq!(*x, 12); let raw = x as *mut i32; unsafe { *raw = 42; } assert_eq!(*x, 42); let raw = x as *mut i32; unsafe { *raw = 12; } *x = 23; assert_eq!(*x, 23); } fn main() { basic_raw(); }