2018-10-17 08:15:53 -05:00
|
|
|
fn basic_raw() {
|
|
|
|
let mut x = 12;
|
|
|
|
let x = &mut x;
|
|
|
|
|
|
|
|
assert_eq!(*x, 12);
|
|
|
|
|
|
|
|
let raw = x as *mut i32;
|
2022-06-20 18:00:37 -05:00
|
|
|
unsafe {
|
|
|
|
*raw = 42;
|
|
|
|
}
|
2018-10-17 08:15:53 -05:00
|
|
|
|
|
|
|
assert_eq!(*x, 42);
|
|
|
|
|
|
|
|
let raw = x as *mut i32;
|
2022-06-20 18:00:37 -05:00
|
|
|
unsafe {
|
|
|
|
*raw = 12;
|
|
|
|
}
|
2018-10-17 08:15:53 -05:00
|
|
|
*x = 23;
|
|
|
|
|
|
|
|
assert_eq!(*x, 23);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
basic_raw();
|
|
|
|
}
|