diff options
| author | Chris Wong <lambda.fairy@gmail.com> | 2015-04-19 21:27:19 +1200 |
|---|---|---|
| committer | Chris Wong <lambda.fairy@gmail.com> | 2015-04-21 17:13:36 +1200 |
| commit | 1131bc0a0f9d4ce920f239dccbd0fcfe1c940548 (patch) | |
| tree | b020e8d15fa077748f031c429886d95415ac7a14 /src/libstd/fs.rs | |
| parent | 21c48c3e823ed21266e96779d700946db957a965 (diff) | |
| download | rust-1131bc0a0f9d4ce920f239dccbd0fcfe1c940548.tar.gz rust-1131bc0a0f9d4ce920f239dccbd0fcfe1c940548.zip | |
Implement Debug for File
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/fs.rs')
| -rw-r--r-- | src/libstd/fs.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 8af3311c426..e8cdee9aca4 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -19,6 +19,7 @@ use core::prelude::*; +use fmt; use io::{self, Error, ErrorKind, SeekFrom, Seek, Read, Write}; use path::{Path, PathBuf}; use sys::fs2 as fs_imp; @@ -305,6 +306,12 @@ impl FromInner<fs_imp::File> for File { } } +impl fmt::Debug for File { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.inner.fmt(f) + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl Read for File { fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { |
