Skip to content

Commit e1e7422

Browse files
committed
Windows: fix FileType PartialEq implementation
1 parent 3bfb6af commit e1e7422

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

library/std/src/sys/fs/windows.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use crate::alloc::{Layout, alloc, dealloc};
44
use crate::borrow::Cow;
55
use crate::ffi::{OsStr, OsString, c_void};
6+
use crate::hash::{Hash, Hasher};
67
use crate::io::{self, BorrowedCursor, Error, IoSlice, IoSliceMut, SeekFrom};
78
use crate::mem::{self, MaybeUninit, offset_of};
89
use crate::os::windows::io::{AsHandle, BorrowedHandle};
@@ -39,7 +40,7 @@ pub struct FileAttr {
3940
file_index: Option<u64>,
4041
}
4142

42-
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
43+
#[derive(Copy, Clone, Eq, Debug)]
4344
pub struct FileType {
4445
attributes: u32,
4546
reparse_tag: u32,
@@ -1140,6 +1141,18 @@ impl FileType {
11401141
}
11411142
}
11421143

1144+
impl PartialEq for FileType {
1145+
fn eq(&self, other: &Self) -> bool {
1146+
self.is_directory() == other.is_directory() && self.is_symlink() == other.is_symlink()
1147+
}
1148+
}
1149+
1150+
impl Hash for FileType {
1151+
fn hash<H: Hasher>(&self, state: &mut H) {
1152+
state.write(&[self.is_directory() as u8, self.is_symlink() as u8]);
1153+
}
1154+
}
1155+
11431156
impl DirBuilder {
11441157
pub fn new() -> DirBuilder {
11451158
DirBuilder

0 commit comments

Comments
 (0)