知识卡片
复制多份数据增加同步负担
同时按到达次序和姓名保存完整Guest副本,能避免借用关系,却让地址等字段更新必须同步多份对象。数据小且不变时复制可简化设计;有修改时应先明确唯一真源与其他视图关系,不能只以编译容易作为模型正确的依据。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Chapter 3. Concepts Data structure design · 查看原书依据
cloning copes poorly if the data can be modified. For example, if the address for a Guest needs to be updated, you have to find both versions and ensure they stay in sync. Another possible approach is to add another layer of indirection, treating the Vec<Guest> as the owner and using an index into that vector for the name lookups: mod indexed { use super::Gu
参考来源
- 位置:《Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)》第3章《Data structure design》(spine7;extracted/Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)/_epub-src/OEBPS/ch03.html;u094-ch03-018)。
- 结论依据:原文在“cloning copes poorly”附近的定义、例子或代码支撑本卡核心说明:同时按到达次序和姓名保存完整Guest副本,能避免借用关系,却让地址等字段更新必须同步多份对象。边界按已读前提解释;示例未执行。
- 原始内容:cloning copes poorly if the data can be modified. For example, if the address for a Guest needs to be updated, you have to find both versions and ensure they stay in sync. Another possible approach is to add another layer of indirection, treating the Vec<Guest> as the owner and using an index into that vector for the name lookups: mod indexed { use super::Gu