PrefixComponent in std::path - Rust (original) (raw)
Struct PrefixComponent
1.0.0 · Source
pub struct PrefixComponent<'a> { /* private fields */ }
Expand description
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 thePrefix 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!(),
}
1.0.0 · Source
Returns the parsed prefix data.
See Prefix’s documentation for more information on the different kinds of prefixes.
1.0.0 · Source
Returns the raw OsStr slice for this prefix.
Tests for self
and other
values to be equal, and is used by ==
.
Tests for !=
. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method returns an ordering between self
and other
values if one exists. Read more
Tests less than (for self
and other
) and is used by the <
operator. Read more
Tests less than or equal to (for self
and other
) and is used by the<=
operator. Read more
Tests greater than (for self
and other
) and is used by the >
operator. Read more
Tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more