Implement masking in FileType hashing on Unix
Commit 77005950f09d2f9ba54962bf5adc3f2bc3a7213f implemented masking of FileType to fix an issue[^1] in the semantic of FileType comparison. This commit introduces masking to Hash to maintain the invariant that x == y => hash(x) == hash(y). [^1]: https://github.com/rust-lang/rust/issues/104900
This commit is contained in:
parent
6259028862
commit
4198d2975d
@ -332,7 +332,7 @@ pub struct FileTimes {
|
||||
modified: Option<SystemTime>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Eq, Hash, Debug)]
|
||||
#[derive(Copy, Clone, Eq, Debug)]
|
||||
pub struct FileType {
|
||||
mode: mode_t,
|
||||
}
|
||||
@ -342,6 +342,13 @@ impl PartialEq for FileType {
|
||||
self.masked() == other.masked()
|
||||
}
|
||||
}
|
||||
|
||||
impl core::hash::Hash for FileType {
|
||||
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
||||
self.masked().hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DirBuilder {
|
||||
mode: mode_t,
|
||||
|
Loading…
x
Reference in New Issue
Block a user