知识卡片
显式解引用访问整个值
&u64 是对整数的引用。当函数需要 u64 时,用 *elem 访问它指向的值,u64 的 Copy 规则允许复制后传给函数。点号在访问字段或方法时通常会自动解引用;需要通过可变引用更新整个位置时,可以写 *slot = new_value。
关联阅读:[[选择拥有或借用的迭代]]。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Expressions 显式访问引用指向的值 · 查看原书依据
The unary * operator is used to access the value pointed to by a reference.
参考来源
- 位置:《Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)》第05章《Expressions》|显式访问引用指向的值,来源项目 `book-source`,`extracted/Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)/_epub-src/OEBPS/ch05.xhtml#reference-operators`
- 结论依据:原文用向量的共享迭代和 draw_triangle 的参数说明何时需要写显式的 *。
- 原始内容:The unary * operator is used to access the value pointed to by a reference.