Comments (4)
Hash
is not a cryptographic hash, so it does not promise a collision probability so low that practically all inputs map to distinct outputs. So if the correctness of your program relies on the absence of collisions then it's your program that's wrong, not Hash
.
There may be some quality-of-implementation argument about avoiding collisions for data patterns that are likely to coexist. I'm not sure if it is the case here, I'll have to think about it. And even if it is then there also is the matter of making such a avoidance fast. The current code is optimized for speed.
from rust.
I think that's a fair point, but the current implementation already goes out if its way to create equal hashes for paths like foo/./bar
and foo/bar
— why is foobar
and foo/bar
different? It seems like a very surprising collision for a user to encounter.
Thanks for taking a look!
from rust.
I think that's a fair point, but the current implementation already goes out if its way to create equal hashes for paths like foo/./bar and foo/bar — why is foobar and foo/bar different?
The difference is that Hash
is a companion for Eq
. If things compare equal then they must hash the same because that's what hashmaps rely on. foo/./bar
and foo/bar
do compare equally because Components
normalizes the dot away. Therefore they must hash equally, which is why Hash must spend effort on that.
Things comparing inequal does not require the Hash to be different. Instead it's only a matter of quality-of-implementation whether they produce distinct hashes, not a matter of correctness.
from rust.
That's a great point, thanks for clarifying. I agree this is not a "correctness" problem, but more of a practical consideration for the hashing algorithm.
from rust.
Related Issues (20)
- internal compiler error: cannot convert `'{erased}` to a region vid HOT 1
- ICE `index out of bounds: the len is 0 but the index is 0` HOT 1
- `binary_asm_labels` should suggest a change HOT 3
- ICE: `bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32` HOT 4
- ICE: `failed to resolve instance for ErrorGuaranteed()` HOT 1
- aarch64-pointer-auth test failing on LLVM 19 HOT 1
- Poorly-documented safety assumptions in `unix::stack_overflow::init` HOT 6
- Bootstrap using `set_times` on a read-only file
- Compiler marks import as unnecessary when it isn't (panic_handler) HOT 4
- Corrupted data trashes the output HOT 8
- Confusing CI error when compiler build fails HOT 8
- unreachable pattern lint should report some (or all) of the earlier match arms that subsume the unreachable one HOT 6
- Compiler unexpectedly panicked - async HOT 4
- ICE: `unexpected value of coverage attribute` HOT 1
- ICE: `typeid_for_instance: couldn't get fn_abi of instance`
- High failure rate on Windows MSVC CI with filesystem errors HOT 3
- `#[expect(unused_imports)]` does not work correctly on grouped imports HOT 8
- Solve the pinned memchr problem
- `doctest` line number is incorrect if used with #![doc = include_str!()] HOT 6
- `tests/run-make/print-target-list` fails for csky-unknown-linux-gnuabiv2 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust.