Skip to content

Commit a2772c3

Browse files
authored
Rollup merge of rust-lang#75284 - pickfire:patch-7, r=LukasKalbertodt
Show relative example for Path ancestors
2 parents 2550e2c + 6899cac commit a2772c3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

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)