知识卡片
哈希派生依赖成员哈希
Hash 把值的各组成送给哈希器。派生适合字段组合正好表达键的身份。自定义相等条件时,相等的两个键须有一致的哈希行为,否则容器查找不可靠。不同键发生哈希碰撞仍可由相等比较区分。
相关卡片 [[Eq要求相等关系自反]]
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 附录 C · 可派生的 trait Clone and Copy for Duplicating Values · 查看原书依据
The Hash trait allows you to take an instance of a type of arbitrary size and map that instance to a value of fixed size using a hash function. Deriving Hash implements the hash method. The derived implementation of the hash method combines the result of calling hash on each of the parts of the type, meaning all fields or values must also implement Hash to derive Hash.
参考来源
- 位置:《The Rust Programming Language(第2版)》附录 C · 可派生的 trait(来源项目 a19c7933-4eda-4176-aebd-30fe7e1ad292,`extracted/The Rust Programming Language(第2版)/_epub-src/b03.xhtml`,块 0041)
- 结论依据:原文说明派生 Hash 会结合各部分的 hash 结果。
- 原始内容:The Hash trait allows you to take an instance of a type of arbitrary size and map that instance to a value of fixed size using a hash function. Deriving Hash implements the hash method. The derived implementation of the hash method combines the result of calling hash on each of the parts of the type, meaning all fields or values must also implement Hash to derive Hash.