diff options
author | Andy Gauge <andygauge@gmail.com> | 2017-07-03 22:00:55 +0300 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2017-07-15 19:58:20 +0300 |
commit | 378cb0742ea9f67c7de97dee56372d684100e40a (patch) | |
tree | c1b5a024a1c14f6103250d7f1da58134f5900585 | |
parent | f216fcb1e50267fbe30dd0b5a6c09698110488c3 (diff) |
Extended documentation to include Errors section for `Iter` (`Iterator::next()`), `FilterEntry` (`Iterator::next()`), and `DirEntry::metadata()`
-rw-r--r-- | src/lib.rs | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -526,7 +526,12 @@ pub struct DirEntry { impl Iterator for IntoIter { type Item = Result<DirEntry>; - + /// Advances the iterator and returns the next value. + /// + /// # Errors + /// + /// If the iterator fails to retrieve the next value, this method returns an error value. + /// The error will be wrapped in an Option::Some. fn next(&mut self) -> Option<Result<DirEntry>> { if let Some(start) = self.start.take() { let dent = itry!(DirEntry::from_link(0, start)); @@ -843,7 +848,13 @@ impl DirEntry { /// If this entry is a symbolic link and `follow_links` is enabled, then /// `std::fs::metadata` is called instead. /// + /// # Errors + /// + /// Similar to [`std::fs::metadata`], returns errors for path values that the program does not + /// have permissions to access or if the path does not exist. + /// /// [`follow_links`]: struct.WalkDir.html#method.follow_links + /// [`std::fs::metadata`]: https://doc.rust-lang.org/std/fs/fn.metadata.html pub fn metadata(&self) -> Result<fs::Metadata> { if self.follow_link { fs::metadata(&self.path) @@ -1003,7 +1014,12 @@ pub struct FilterEntry<I, P> { impl<P> Iterator for FilterEntry<IntoIter, P> where P: FnMut(&DirEntry) -> bool { type Item = Result<DirEntry>; - + /// Advances the iterator and returns the next value. + /// + /// # Errors + /// + /// If the iterator fails to retrieve the next value, this method returns an error value. + /// The error will be wrapped in an Option::Some. fn next(&mut self) -> Option<Result<DirEntry>> { loop { let dent = match self.it.next() { |