You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ cat sample.rs
fn main() {
let mut x = 2;
let y = &x as *mut i32;
}
$ rustc sample.rs
sample.rs:3:11: 3:25 error: casting `&i32` as `*mut i32` is invalid
sample.rs:3 let y = &x as *mut i32;
^~~~~~~~~~~~~~
error: aborting due to previous error
创建一个裸指针:
let a = 1;let b = &a as*consti32;letmut x = 2;let y = &x as*muti32;
unsafe-rawpointer/raw-pointer.md