知识卡片
解引用目标需要唯一
Deref用关联类型Target指定一个实现的解引用目标,让*x有确定含义。若同一类型可随意选择多个泛型目标,解引用表达式便难以确定类型。DerefMut提供可变目标引用;这些trait带有编译器特殊处理,适合智能指针式访问。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Chapter 1. Types Pointer Traits · 查看原书依据
associated type named Target. This technical aside provides a contrast to two other standard pointer traits, the AsRef and AsMut traits. These traits don’t induce special behavior in the compiler but allow conversions to a reference or mutable reference via an explicit call to their trait functions (as_ref() and as_mut(), respectively). The destination type
参考来源
- 位置:《Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)》第1章《Pointer Traits》(spine5;extracted/Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)/_epub-src/OEBPS/ch01.html;u041-ch01-055)。
- 结论依据:原文在“associated type named Target”附近的定义、例子或代码支撑本卡核心说明:Deref用关联类型Target指定一个实现的解引用目标,让*x有确定含义。边界按已读前提解释;示例未执行。
- 原始内容:associated type named Target. This technical aside provides a contrast to two other standard pointer traits, the AsRef and AsMut traits. These traits don’t induce special behavior in the compiler but allow conversions to a reference or mutable reference via an explicit call to their trait functions (as_ref() and as_mut(), respectively). The destination type