Rollup merge of #37221 - diwic:6a-readdir-debug, r=alexcrichton
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>
This commit is contained in:
commit
184ee985f8
3 changed files with 17 additions and 0 deletions
|
|
@ -83,6 +83,7 @@ pub struct Metadata(fs_imp::FileAttr);
|
|||
///
|
||||
/// [`io::Result`]: ../io/type.Result.html
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[derive(Debug)]
|
||||
pub struct ReadDir(fs_imp::ReadDir);
|
||||
|
||||
/// Entries returned by the [`ReadDir`] iterator.
|
||||
|
|
|
|||
|
|
@ -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>;
|
||||
|
||||
|
|
|
|||
|
|
@ -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>> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue