Struct std::path::PrefixComponent
1.0.0 · source · pub struct PrefixComponent<'a> { /* private fields */ }
Expand description
包装 Windows 路径前缀及其未解析的字符串表示形式的结构体。
除了由 kind
返回的已解析 Prefix
信息外,PrefixComponent
还保存由 as_os_str
返回的原始和未解析的 OsStr
切片。
可以通过与 Component
上的 Prefix
variant 匹配来获得此 struct
的实例。
在 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!(),
}
RunImplementations§
Trait Implementations§
source§impl<'a> Clone for PrefixComponent<'a>
impl<'a> Clone for PrefixComponent<'a>
source§fn clone(&self) -> PrefixComponent<'a>
fn clone(&self) -> PrefixComponent<'a>
返回值的副本。 Read more
source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
从
source
执行复制分配。 Read moresource§impl<'a> Debug for PrefixComponent<'a>
impl<'a> Debug for PrefixComponent<'a>
source§impl Hash for PrefixComponent<'_>
impl Hash for PrefixComponent<'_>
source§impl Ord for PrefixComponent<'_>
impl Ord for PrefixComponent<'_>
source§impl<'a> PartialEq<PrefixComponent<'a>> for PrefixComponent<'a>
impl<'a> PartialEq<PrefixComponent<'a>> for PrefixComponent<'a>
source§impl<'a> PartialOrd<PrefixComponent<'a>> for PrefixComponent<'a>
impl<'a> PartialOrd<PrefixComponent<'a>> for PrefixComponent<'a>
source§fn partial_cmp(&self, other: &PrefixComponent<'a>) -> Option<Ordering>
fn partial_cmp(&self, other: &PrefixComponent<'a>) -> Option<Ordering>
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
从拥有的值中借用。 Read more