Show relative example for Path ancestors

This commit is contained in:
Ivan Tham 2020-08-08 17:53:16 +08:00 committed by GitHub
parent d19d7e2755
commit a11c27925d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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