diff options
| author | David Henningsson <diwic@ubuntu.com> | 2016-10-16 20:38:56 +0200 |
|---|---|---|
| committer | David Henningsson <diwic@ubuntu.com> | 2016-10-16 20:42:55 +0200 |
| commit | e4ed345b2ca84db1b3300661aa3940afc0c0cbf0 (patch) | |
| tree | 5fee90aab6c5a451d27dac06baf4652f4d997087 /src/libstd/sys | |
| parent | 6dc035ed911672c6a1f7afc9eed15fb08e574e5b (diff) | |
| download | rust-e4ed345b2ca84db1b3300661aa3940afc0c0cbf0.tar.gz rust-e4ed345b2ca84db1b3300661aa3940afc0c0cbf0.zip | |
impl Debug for ReadDir
It is good practice to implement Debug for public types, and indicating what directory you're reading seems useful. Signed-off-by: David Henningsson <diwic@ubuntu.com>
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/unix/fs.rs | 8 | ||||
| -rw-r--r-- | src/libstd/sys/windows/fs.rs | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index fe8cbc84215..b77008676b1 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -193,6 +193,14 @@ impl FromInner<u32> for FilePermissions { } } +impl fmt::Debug for ReadDir { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + // This will only be called from std::fs::ReadDir, which will add a "ReadDir()" frame. + // Thus the result will be e g 'ReadDir("/home")' + fmt::Debug::fmt(&*self.root, f) + } +} + impl Iterator for ReadDir { type Item = io::Result<DirEntry>; diff --git a/src/libstd/sys/windows/fs.rs b/src/libstd/sys/windows/fs.rs index a927eae020d..98fd15f863b 100644 --- a/src/libstd/sys/windows/fs.rs +++ b/src/libstd/sys/windows/fs.rs @@ -81,6 +81,14 @@ pub struct FilePermissions { attrs: c::DWORD } pub struct DirBuilder; +impl fmt::Debug for ReadDir { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + // This will only be called from std::fs::ReadDir, which will add a "ReadDir()" frame. + // Thus the result will be e g 'ReadDir("C:\")' + fmt::Debug::fmt(&*self.root, f) + } +} + impl Iterator for ReadDir { type Item = io::Result<DirEntry>; fn next(&mut self) -> Option<io::Result<DirEntry>> { |
