advance/unsafe/superpowers #767
Replies: 14 comments 9 replies
-
|
讲的真不错 |
Beta Was this translation helpful? Give feedback.
-
|
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.
-
|
众所周知,七种武器只有六种 |
Beta Was this translation helpful? Give feedback.
-
|
我反注释了 let message = get_str_at_location(1000, 10); 好像什么也没发生的样子。。 |
Beta Was this translation helpful? Give feedback.
-
|
在 unsafe 函数体中使用 unsafe 语句块是多余的行为 在最新版的rust中(rust2024),unsafe fn 中的 unsafe 操作仍需要 unsafe {} 块 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
advance/unsafe/superpowers
https://course.rs/advance/unsafe/superpowers.html
Beta Was this translation helpful? Give feedback.
All reactions