rust/tests/pass/ptr_raw.rs
2022-06-20 16:09:45 -07:00

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