pub unsafe trait PathLike<'data>: Sized {
// Required method
fn into_path_bytes(self) -> Cow<'data, [u8]>;
// Provided method
fn into_path(self) -> Cow<'data, Path> { ... }
}Expand description
A trait that represents a sequence of bytes that can be interpreted as a path.
This is better than AsRef<Path> for the following reasons:
- Doesn’t actually require
PathorOsStr, thus working in#[no_std]environments - Preserves ownership, being closer to
into Into<Cow>in this regard.
§Safety
Only implement this for types whose representation is the same as that of OsStr. Currently
in the standard library those are str, OsStr & Path (and all their varieties)
Required Methods§
Sourcefn into_path_bytes(self) -> Cow<'data, [u8]>
fn into_path_bytes(self) -> Cow<'data, [u8]>
Convert this to a possibly owned sequence of bytes that’s guaranteed to uphold the same
guarantees as an OsStr.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.