知识卡片

普通读书笔记卡 · 10504.f.1.a · 生成模型:未记录

原始指针解引用边界

理解等级:中级

*const T 和 *mut T 是原始指针,可用于调用 C 库或实现内存数据结构。解引用这类地址必须在 unsafe 内进行;这要求实现者自行满足地址有效等前提。普通 Rust 借用则把访问约束交给类型和借用检查。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《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