知识卡片

普通读书笔记卡 · 6074.i.1.b

容器替换需要检查行为差异

理解等级:中级

alloc提供BTreeMap与BTreeSet,而标准HashMap、HashSet属于std,默认随机种子等能力依赖额外环境。改成树形集合时需检查键的Ord、迭代顺序和复杂度变化,不能只把类型名机械替换。第三方no_std哈希或同步方案需按目标能力另行评估。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Chapter 6. Beyond Standard Rust alloc · 查看原书依据

      HashMap and HashSet are specific to std, not alloc. That’s because these hash-based containers rely on random seeds to protect against hash collision attacks, but safe random number generation requires assistance from the operating system—which alloc can’t assume exists. Another notable absence is synchronization functionality like std::sync::Mutex, which is

    参考来源

    - 位置:《Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)》第6章《alloc》(spine10;extracted/Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)/_epub-src/OEBPS/ch06.html;u169-ch06-004)。 - 结论依据:原文在“HashMap and HashSet”附近的定义、例子或代码支撑本卡核心说明:alloc提供BTreeMap与BTreeSet,而标准HashMap、HashSet属于std,默认随机种子等能力依赖额外环境。边界按已读前提解释;示例未执行。 - 原始内容:HashMap and HashSet are specific to std, not alloc. That’s because these hash-based containers rely on random seeds to protect against hash collision attacks, but safe random number generation requires assistance from the operating system—which alloc can’t assume exists. Another notable absence is synchronization functionality like std::sync::Mutex, which is