Skip to content

Commit a11c279

Browse files
authored
Show relative example for Path ancestors
1 parent d19d7e2 commit a11c279

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)