Struct Components

struct Components<'a> { ... }

An iterator over the Components of a Path.

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

Examples

use std::path::Path;

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

for component in path.components() {
    println!("{component:?}");
}

Implementations

impl<'a> Components<'a>

fn as_path(self: &Self) -> &'a Path

Extracts a slice corresponding to the portion of the path remaining for iteration.

Examples

use std::path::Path;

let mut components = Path::new("/tmp/foo/bar.txt").components();
components.next();
components.next();

assert_eq!(Path::new("foo/bar.txt"), components.as_path());

impl AsRef for Components<'_>

fn as_ref(self: &Self) -> &OsStr

impl AsRef for Components<'_>

fn as_ref(self: &Self) -> &Path

impl Debug for Components<'_>

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

impl Eq for Components<'_>

impl FusedIterator for Components<'_>

impl Ord for Components<'_>

fn cmp(self: &Self, other: &Self) -> cmp::Ordering

impl<'a> Clone for Components<'a>

fn clone(self: &Self) -> Components<'a>

impl<'a> DoubleEndedIterator for Components<'a>

fn next_back(self: &mut Self) -> Option<Component<'a>>

impl<'a> Freeze for Components<'a>

impl<'a> Iterator for Components<'a>

fn next(self: &mut Self) -> Option<Component<'a>>

impl<'a> PartialEq for Components<'a>

fn eq(self: &Self, other: &Components<'a>) -> bool

impl<'a> PartialOrd for Components<'a>

fn partial_cmp(self: &Self, other: &Components<'a>) -> Option<cmp::Ordering>

impl<'a> RefUnwindSafe for Components<'a>

impl<'a> Send for Components<'a>

impl<'a> Sync for Components<'a>

impl<'a> Unpin for Components<'a>

impl<'a> UnwindSafe for Components<'a>

impl<I> IntoIterator for Components<'a>

fn into_iter(self: Self) -> I

impl<T> Any for Components<'a>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Components<'a>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Components<'a>

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

impl<T> CloneToUninit for Components<'a>

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

impl<T> From for Components<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Components<'a>

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for Components<'a>

fn into(self: 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 for Components<'a>

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

impl<T, U> TryInto for Components<'a>

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