Enum relative_path::Component[][src]

pub enum Component<'a> {
    CurDir,
    ParentDir,
    Normal(&'a str),
}

A single path component.

Accessed using the RelativePath::components iterator.

Examples

use relative_path::{Component, RelativePath};

let path = RelativePath::new("foo/../bar/./baz");
let mut it = path.components();

assert_eq!(Some(Component::Normal("foo")), it.next());
assert_eq!(Some(Component::ParentDir), it.next());
assert_eq!(Some(Component::Normal("bar")), it.next());
assert_eq!(Some(Component::CurDir), it.next());
assert_eq!(Some(Component::Normal("baz")), it.next());
assert_eq!(None, it.next());

Variants

CurDir

The current directory ..

ParentDir

The parent directory ...

Normal(&'a str)

A normal path component as a string.

Implementations

impl<'a> Component<'a>[src]

pub fn as_str(self) -> &'a str[src]

Extracts the underlying str slice.

Examples

use relative_path::{RelativePath, Component};

let path = RelativePath::new("./tmp/../foo/bar.txt");
let components: Vec<_> = path.components().map(Component::as_str).collect();
assert_eq!(&components, &[".", "tmp", "..", "foo", "bar.txt"]);

Trait Implementations

impl<'a> Clone for Component<'a>[src]

impl<'a> Copy for Component<'a>[src]

impl<'a> Debug for Component<'a>[src]

impl<'a> Eq for Component<'a>[src]

impl<'a> Hash for Component<'a>[src]

impl<'a> Ord for Component<'a>[src]

impl<'a> PartialEq<Component<'a>> for Component<'a>[src]

impl<'a> PartialOrd<Component<'a>> for Component<'a>[src]

impl<'a> StructuralEq for Component<'a>[src]

impl<'a> StructuralPartialEq for Component<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Component<'a>

impl<'a> Send for Component<'a>

impl<'a> Sync for Component<'a>

impl<'a> Unpin for Component<'a>

impl<'a> UnwindSafe for Component<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.