Skip to main content

PathElementCS

Type Alias PathElementCS 

Source
pub type PathElementCS<'a> = PathElementGeneric<'a, CaseSensitive>;
Expand description

Case-sensitive path element (compile-time case sensitivity).

Alias for PathElementGeneric<'a, CaseSensitive>. Implements Hash.

Aliased Type§

pub struct PathElementCS<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> PathElementCS<'a>

Source

pub fn new(original: impl Into<Cow<'a, str>>) -> Result<Self>

Creates a new case-sensitive path element from a string.

§Errors

Returns Error if the name is invalid (empty, ., .., or contains /).

let pe = PathElementCS::new("Hello.txt")?;
assert_eq!(pe.normalized(), "Hello.txt"); // case preserved
Source

pub fn from_bytes(original: impl Into<Cow<'a, [u8]>>) -> Result<Self>

Creates a new case-sensitive path element from a byte slice.

Invalid UTF-8 is accepted; see Normalization pipeline step 0.

§Errors

Returns Error if the name is invalid (empty, ., .., or contains /).

Source

pub fn from_os_str(original: impl Into<Cow<'a, OsStr>>) -> Result<Self>

Available on crate feature std only.

Creates a new case-sensitive path element from an OS string.

Invalid UTF-8 is accepted; see Normalization pipeline step 0.

§Errors

Returns Error if the name is invalid (empty, ., .., or contains /).

Trait Implementations§

Source§

impl Hash for PathElementCS<'_>

Hashes by normalized(), consistent with PartialEq. Only implemented for typed variants, not PathElement.

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> TryFrom<PathElementGeneric<'a, CaseSensitivity>> for PathElementCS<'a>

Attempts to convert a runtime-dynamic PathElement into a PathElementCS.

Succeeds if the element is case-sensitive. On failure, returns the element re-wrapped as a PathElementCI in the Err variant (no data is lost).

Source§

type Error = PathElementGeneric<'a, CaseInsensitive>

The type returned in the event of a conversion error.
Source§

fn try_from(pe: PathElement<'a>) -> Result<Self, Self::Error>

Performs the conversion.