rust/tests/run-pass/ptr_raw.rs
2020-04-16 09:06:21 +02:00

22 lines
291 B
Rust

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();
}