diff options
| author | bors <bors@rust-lang.org> | 2015-04-21 11:46:15 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-04-21 11:46:15 +0000 |
| commit | 77acda1c8ee75f9eb923ddd811ee591951b2d43f (patch) | |
| tree | 790d0641c2cd84fe5901bbd11e66426b588644ca /src/libstd/sys/windows | |
| parent | 3860240b0e124f38483ea4bd070b61d362871ece (diff) | |
| parent | 1131bc0a0f9d4ce920f239dccbd0fcfe1c940548 (diff) | |
| download | rust-77acda1c8ee75f9eb923ddd811ee591951b2d43f.tar.gz rust-77acda1c8ee75f9eb923ddd811ee591951b2d43f.zip | |
Auto merge of #24598 - lfairy:impl-debug-for-file, r=alexcrichton
This patch adds a `Debug` impl for `std::fs::File`. On all platforms (Unix and Windows) it shows the file descriptor. On Linux, it displays the path and access mode as well. Ideally we should show the path/mode for all platforms, not just Linux, but this will do for now. cc #24570
Diffstat (limited to 'src/libstd/sys/windows')
| -rw-r--r-- | src/libstd/sys/windows/fs2.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libstd/sys/windows/fs2.rs b/src/libstd/sys/windows/fs2.rs index 9645c51ec0b..b0515a71229 100644 --- a/src/libstd/sys/windows/fs2.rs +++ b/src/libstd/sys/windows/fs2.rs @@ -14,6 +14,7 @@ use os::windows::prelude::*; use default::Default; use ffi::{OsString, AsOsStr}; +use fmt; use io::{self, Error, SeekFrom}; use libc::{self, HANDLE}; use mem; @@ -271,6 +272,15 @@ impl FromInner<libc::HANDLE> for File { } } +impl fmt::Debug for File { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + // FIXME(#24570): add more info here (e.g. path, mode) + f.debug_struct("File") + .field("handle", &self.handle.raw()) + .finish() + } +} + pub fn to_utf16(s: &Path) -> Vec<u16> { s.as_os_str().encode_wide().chain(Some(0).into_iter()).collect() } |
