← 返回起始笔记位置

知识卡片

普通读书笔记卡 · 6074.a.2.f.1

解引用目标需要唯一

理解等级:中级

Deref用关联类型Target指定一个实现的解引用目标,让*x有确定含义。若同一类型可随意选择多个泛型目标,解引用表达式便难以确定类型。DerefMut提供可变目标引用;这些trait带有编译器特殊处理,适合智能指针式访问。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 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