On this page
Struct std::path::PrefixComponent
pub struct PrefixComponent<'a> { /* private fields */ }
A structure wrapping a Windows path prefix as well as its unparsed string representation.
In addition to the parsed Prefix information returned by kind, PrefixComponent also holds the raw and unparsed OsStr slice, returned by as_os_str.
Instances of this struct can be obtained by matching against the Prefix variant on Component.
Does not occur on Unix.
Examples
use std::path::{Component, Path, Prefix};
use std::ffi::OsStr;
let path = Path::new(r"c:\you\later\");
match path.components().next().unwrap() {
Component::Prefix(prefix_component) => {
assert_eq!(Prefix::Disk(b'C'), prefix_component.kind());
assert_eq!(OsStr::new("c:"), prefix_component.as_os_str());
}
_ => unreachable!(),
}
Implementations
impl<'a> PrefixComponent<'a>
Trait Implementations
impl<'a> Clone for PrefixComponent<'a>
fn clone(&self) -> PrefixComponent<'a>
fn clone_from(&mut self, source: &Self)
source. Read more
impl<'a> Debug for PrefixComponent<'a>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Hash for PrefixComponent<'_>
fn hash<H: Hasher>(&self, h: &mut H)
fn hash_slice<H>(data: &[Self], state: &mut H)
where
H: Hasher,
Self: Sized,
impl Ord for PrefixComponent<'_>
fn cmp(&self, other: &Self) -> Ordering
fn max(self, other: Self) -> Self
where
Self: Sized,
fn min(self, other: Self) -> Self
where
Self: Sized,
fn clamp(self, min: Self, max: Self) -> Self
where
Self: Sized + PartialOrd,
impl<'a> PartialEq for PrefixComponent<'a>
fn eq(&self, other: &PrefixComponent<'a>) -> bool
self and other values to be equal, and is used by ==.
fn ne(&self, other: &Rhs) -> bool
!=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
impl<'a> PartialOrd for PrefixComponent<'a>
fn partial_cmp(&self, other: &PrefixComponent<'a>) -> Option<Ordering>
fn lt(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <= operator. Read more
fn gt(&self, other: &Rhs) -> bool
fn ge(&self, other: &Rhs) -> bool
self and other) and is used by the >= operator. Read more
impl<'a> Copy for PrefixComponent<'a>
impl<'a> Eq for PrefixComponent<'a>
impl<'a> StructuralEq for PrefixComponent<'a>
Auto Trait Implementations
impl<'a> RefUnwindSafe for PrefixComponent<'a>
impl<'a> Send for PrefixComponent<'a>
impl<'a> Sync for PrefixComponent<'a>
impl<'a> Unpin for PrefixComponent<'a>
impl<'a> UnwindSafe for PrefixComponent<'a>
Blanket Implementations
impl<T> Any for T
where
T: 'static + ?Sized,
impl<T> Borrow<T> for T
where
T: ?Sized,
impl<T> BorrowMut<T> for T
where
T: ?Sized,
impl<T> From<T> for T
fn from(t: T) -> T
Returns the argument unchanged.
impl<T, U> Into<U> for T
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> ToOwned for T
where
T: Clone,
type Owned = T
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)
impl<T, U> TryFrom<U> for T
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 T
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/path/struct.PrefixComponent.html