知识卡片
原始指针解引用边界
*const T 和 *mut T 是原始指针,可用于调用 C 库或实现内存数据结构。解引用这类地址必须在 unsafe 内进行;这要求实现者自行满足地址有效等前提。普通 Rust 借用则把访问约束交给类型和借用检查。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Fundamental Types 指针类型说明谁管理内存 · 查看原书依据
are Rust’s raw pointer types, the equivalent of C pointers. They can be dereferenced only in unsafe blocks, code that explicitly opts out
参考来源
- 位置:《Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)》第02章《Fundamental Types》|指针类型说明谁管理内存,来源项目 `book-source`,`extracted/Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)/_epub-src/OEBPS/ch02.xhtml#pointer-types`
- 结论依据:原文把原始指针与 C 指针对应,给出 C 互操作和底层数据结构两个用途,并明确其解引用条件。
- 原始内容:are Rust’s raw pointer types, the equivalent of C pointers. They can be dereferenced only in unsafe blocks, code that explicitly opts out