diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 392c815ef2803..ba58cd9540ade 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -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