diff --git a/library/std/src/sys/fs/windows.rs b/library/std/src/sys/fs/windows.rs index f2d325da35c7d..e6be2c79a148f 100644 --- a/library/std/src/sys/fs/windows.rs +++ b/library/std/src/sys/fs/windows.rs @@ -1022,12 +1022,21 @@ impl FromRawHandle for File { impl fmt::Debug for File { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - // FIXME(#24570): add more info here (e.g., mode) let mut b = f.debug_struct("File"); b.field("handle", &self.handle.as_raw_handle()); if let Ok(path) = get_path(self) { b.field("path", &path); } + + if let Ok(file_attr) = self.file_attr() { + b.field("read", &true); + b.field("write", &file_attr.perm().readonly()); + + // Getting analogue of file mode (unix) using file attributes + // See https://learn.microsoft.com/windows/win32/fileio/file-attribute-constants + b.field("attrs", &file_attr.attributes); + } + b.finish() } }