Struct Ancestors

#[must_use = "iterators are lazy and do nothing unless consumed"]
pub struct Ancestors<'a> { pub(in ::path) next: Option<&'a Path> }

An iterator over Path and its ancestors.

This struct is created by the ancestors method on Path. See its documentation for more.

Examples

use std::path::Path;

let path = Path::new("/foo/bar");

for ancestor in path.ancestors() {
    println!("{}", ancestor.display());
}

Fields

next: Option<&'a Path>

Trait Implementations

impl FusedIterator for Ancestors<'_>

impl<'a> Clone for Ancestors<'a>

fn clone(&self) -> Ancestors<'a>

impl<'a> Copy for Ancestors<'a>

impl<'a> Debug for Ancestors<'a>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl<'a> Iterator for Ancestors<'a>

type Item = &'a Path;
fn next(&mut self) -> Option<Self::Item>

impl<'a> TrivialClone for Ancestors<'a>

Auto Trait Implementations

impl<'a> Freeze for Ancestors<'a>

impl<'a> RefUnwindSafe for Ancestors<'a>

impl<'a> Send for Ancestors<'a>

impl<'a> Sync for Ancestors<'a>

impl<'a> Unpin for Ancestors<'a>

impl<'a> UnsafeUnpin for Ancestors<'a>

impl<'a> UnwindSafe for Ancestors<'a>

Blanket Implementations

impl<I> IntoIterator for Ancestors<'a> where I: Iterator,

type Item = <I as Iterator>::Item;
type IntoIter = I;
fn into_iter(self) -> I

impl<T> Any for Ancestors<'a> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Ancestors<'a> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Ancestors<'a> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for Ancestors<'a> where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for Ancestors<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Printable for Ancestors<'a> where T: Copy + Debug,

impl<T> SizeHint for Ancestors<'a> where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for Ancestors<'a>

impl<T> ToOwned for Ancestors<'a> where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for Ancestors<'a> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Ancestors<'a> where U: Into<T>,

type Error = Infallible;
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto<U> for Ancestors<'a> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>