Hash implementation of Utf8PathBuf doesn't match Utf8Path
CryZe opened this issue · comments
Utf8PathBuf
implements Borrow<Utf8Path>
but the following invariant of Borrow
does not hold:
In particular Eq, Ord and Hash must be equivalent for borrowed and owned values: x.borrow() == y.borrow() should give the same result as x == y.
That means that Utf8PathBuf and Utf8Path of the same content (i.e. partial_cmp returning Same) need to Hash the same. This does not currently seem to be true:
[src/main.rs:10] hash(camino::Utf8Path::new("db4")) = 2500477520987573830
[src/main.rs:14] hash(camino::Utf8PathBuf::from("db4")) = 12412650977873828595
with
fn hash(value: impl Hash) -> u64 {
let mut hasher = std::collections::hash_map::DefaultHasher::new();
value.hash(&mut hasher);
hasher.finish()
}
Whoops, will fix ASAP!