advance/unsafe/superpowers #767
Replies: 11 comments 9 replies
-
actix-web 的前作者为啥被喷 |
Beta Was this translation helpful? Give feedback.
-
还是裸指针用着顺手:-) |
Beta Was this translation helpful? Give feedback.
-
有一点点迷糊,请问这里不是把n drop掉了吗。
|
Beta Was this translation helpful? Give feedback.
-
pub fn drop(_x: T) { } |
Beta Was this translation helpful? Give feedback.
-
fn get_memory_location() -> (usize, usize) { fn main() { ); 上面代码中,主函数调用get_memory_location()完成后,函数内string是不是被drop了?如果是的话,为何主函数内还能获取message的值为“Hello world" |
Beta Was this translation helpful? Give feedback.
-
请问裸指针指向的内存空间如何drop(free)? |
Beta Was this translation helpful? Give feedback.
-
过度用unsafe,干嘛不直接用C好了:D |
Beta Was this translation helpful? Give feedback.
-
能讲一讲cxx怎么用吗? |
Beta Was this translation helpful? Give feedback.
-
我叫野指针,我为你回首🌹 |
Beta Was this translation helpful? Give feedback.
-
裸指针(raw ptr)可以实现对不可变值进行更改 let var = 114514;
println!("{var}");
let mut_ref = unsafe { (&var as *const i32 as *mut i32).as_mut() }.unwrap();
*mut_ref = 1919810;
println!("{var}"); |
Beta Was this translation helpful? Give feedback.
-
advance/unsafe/superpowers
https://course.rs/advance/unsafe/superpowers.html
Beta Was this translation helpful? Give feedback.
All reactions