Skip to content

Commit 27b864b

Browse files
authored
Rollup merge of #75284 - pickfire:patch-7, r=LukasKalbertodt
Show relative example for Path ancestors
2 parents cb75fea + a11c279 commit 27b864b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

library/std/src/path.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,6 +1992,13 @@ impl Path {
19921992
/// assert_eq!(ancestors.next(), Some(Path::new("/foo")));
19931993
/// assert_eq!(ancestors.next(), Some(Path::new("/")));
19941994
/// assert_eq!(ancestors.next(), None);
1995+
///
1996+
/// let mut ancestors = Path::new("../foo/bar").ancestors();
1997+
/// assert_eq!(ancestors.next(), Some(Path::new("../foo/bar")));
1998+
/// assert_eq!(ancestors.next(), Some(Path::new("../foo")));
1999+
/// assert_eq!(ancestors.next(), Some(Path::new("..")));
2000+
/// assert_eq!(ancestors.next(), Some(Path::new("")));
2001+
/// assert_eq!(ancestors.next(), None);
19952002
/// ```
19962003
///
19972004
/// [`None`]: ../../std/option/enum.Option.html#variant.None

0 commit comments

Comments
 (0)