Rollup merge of #75284 - pickfire:patch-7, r=LukasKalbertodt

Show relative example for Path ancestors
This commit is contained in:
Yuki Okushi 2020-08-09 06:41:27 +09:00 committed by GitHub
commit 27b864b154
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1992,6 +1992,13 @@ impl Path {
/// assert_eq!(ancestors.next(), Some(Path::new("/foo")));
/// assert_eq!(ancestors.next(), Some(Path::new("/")));
/// assert_eq!(ancestors.next(), None);
///
/// let mut ancestors = Path::new("../foo/bar").ancestors();
/// assert_eq!(ancestors.next(), Some(Path::new("../foo/bar")));
/// assert_eq!(ancestors.next(), Some(Path::new("../foo")));
/// assert_eq!(ancestors.next(), Some(Path::new("..")));
/// assert_eq!(ancestors.next(), Some(Path::new("")));
/// assert_eq!(ancestors.next(), None);
/// ```
///
/// [`None`]: ../../std/option/enum.Option.html#variant.None