From a11c27925d607f7e1f9bf5a1306b2f2789e55624 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Sat, 8 Aug 2020 17:53:16 +0800 Subject: [PATCH] Show relative example for Path ancestors --- library/std/src/path.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 392c815ef28..ba58cd9540a 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