Rework Path::ancestors documentation to remove unwraps
If you take a quick glance at the documentation for Path::ancestors, the unwraps take the natural focus. Potentially indicating that ancestors might panic. In the reworked version I've also moved the link with parent returning None and that the iterator will always yield &self to before the yield examples.
This commit is contained in:
parent
bc8ad6a41e
commit
6b0d3663c1
@ -2278,10 +2278,9 @@ impl Path {
|
|||||||
/// Produces an iterator over `Path` and its ancestors.
|
/// Produces an iterator over `Path` and its ancestors.
|
||||||
///
|
///
|
||||||
/// The iterator will yield the `Path` that is returned if the [`parent`] method is used zero
|
/// The iterator will yield the `Path` that is returned if the [`parent`] method is used zero
|
||||||
/// or more times. That means, the iterator will yield `&self`, `&self.parent().unwrap()`,
|
/// or more times. If the [`parent`] method returns [`None`], the iterator will do likewise.
|
||||||
/// `&self.parent().unwrap().parent().unwrap()` and so on. If the [`parent`] method returns
|
/// The iterator will always yield at least one value, namely `Some(&self)`. Next it will yield
|
||||||
/// [`None`], the iterator will do likewise. The iterator will always yield at least one value,
|
/// `&self.parent()`, `&self.parent().and_then(Path::parent)` and so on.
|
||||||
/// namely `&self`.
|
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
Loading…
x
Reference in New Issue
Block a user