diff options
author | Thayne McCombs <astrothayne@gmail.com> | 2017-07-31 14:08:59 +0300 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2017-07-31 14:08:59 +0300 |
commit | 079d1456eb7ba94888a4ce2b82bc814393df7ff4 (patch) | |
tree | 48f3ff171d47dd871ba3f326799a9cff13dacd8b | |
parent | a4cc6e88e7d4b10d6cbf47a29bcf03b8bdef1405 (diff) |
Derive Debug for public structs
Fixes #34
-rw-r--r-- | src/lib.rs | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -241,6 +241,7 @@ pub type Result<T> = ::std::result::Result<T, Error>; /// /// Note that when following symbolic/soft links, loops are detected and an /// error is reported. +#[derive(Debug)] pub struct WalkDir { opts: WalkDirOptions, root: PathBuf, @@ -255,6 +256,25 @@ struct WalkDirOptions { contents_first: bool, } +impl fmt::Debug for WalkDirOptions { + fn fmt(&self, f: &mut fmt::Formatter) -> ::std::result::Result<(), fmt::Error> { + let sorter_str = if self.sorter.is_some() { + // FnMut isn't `Debug` + "Some(...)" + } else { + "None" + }; + f.debug_struct("WalkDirOptions") + .field("follow_links", &self.follow_links) + .field("max_open", &self.max_open) + .field("min_depth", &self.min_depth) + .field("max_depth", &self.max_depth) + .field("sorter", &sorter_str) + .field("contents_first", &self.contents_first) + .finish() + } +} + impl WalkDir { /// Create a builder for a recursive directory iterator starting at the /// file path `root`. If `root` is a directory, then it is the first item @@ -458,6 +478,7 @@ impl IntoIterator for WalkDir { /// /// [`WalkDir`]: struct.WalkDir.html /// [`.into_iter()`]: struct.WalkDir.html#into_iter.v +#[derive(Debug)] pub struct IntoIter { /// Options specified in the builder. Depths, max fds, etc. opts: WalkDirOptions, @@ -502,6 +523,7 @@ pub struct IntoIter { /// /// [`fs::ReadDir`]: https://doc.rust-lang.org/stable/std/fs/struct.ReadDir.html /// [`Vec<fs::DirEntry>`]: https://doc.rust-lang.org/stable/std/vec/struct.Vec.html +#[derive(Debug)] enum DirList { /// An opened handle. /// @@ -1055,6 +1077,7 @@ impl fmt::Debug for DirEntry { /// [`.into_iter()`]: struct.WalkDir.html#into_iter.v /// [`min_depth`]: struct.WalkDir.html#method.min_depth /// [`max_depth`]: struct.WalkDir.html#method.max_depth +#[derive(Debug)] pub struct FilterEntry<I, P> { it: I, predicate: P, |