]> git.lizzy.rs Git - rust.git/blobdiff - library/std/src/sys/unix/fs.rs
Implement masking in FileType comparison on Unix
[rust.git] / library / std / src / sys / unix / fs.rs
index 37a49f2d78acdb24179d078f4e84b32ed017a573..382204d689318290132108ba8ef61aaf8a43560b 100644 (file)
@@ -332,11 +332,16 @@ pub struct FileTimes {
     modified: Option<SystemTime>,
 }
 
-#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
+#[derive(Copy, Clone, Eq, Hash, Debug)]
 pub struct FileType {
     mode: mode_t,
 }
 
+impl PartialEq for FileType {
+    fn eq(&self, other: &Self) -> bool {
+        self.masked() == other.masked()
+    }
+}
 #[derive(Debug)]
 pub struct DirBuilder {
     mode: mode_t,
@@ -550,6 +555,10 @@ pub fn is_symlink(&self) -> bool {
     pub fn is(&self, mode: mode_t) -> bool {
         self.mode & libc::S_IFMT == mode
     }
+
+    fn masked(&self) -> mode_t {
+        self.mode & libc::S_IFMT
+    }
 }
 
 impl FromInner<u32> for FilePermissions {