Struct std::ffi::OsStr
[−]
[src]
pub struct OsStr { // some fields omitted }1.0.0
Slices into OS strings (see OsString
).
Methods
impl OsStr
fn new<S: AsRef<OsStr> + ?Sized>(s: &S) -> &OsStr
Coerces into an OsStr
slice.
fn to_str(&self) -> Option<&str>
Yields a &str
slice if the OsStr
is valid Unicode.
This conversion may entail doing a check for UTF-8 validity.
fn to_string_lossy(&self) -> Cow<str>
Converts an OsStr
to a Cow<str>
.
Any non-Unicode sequences are replaced with U+FFFD REPLACEMENT CHARACTER.
fn to_os_string(&self) -> OsString
Copies the slice into an owned OsString
.
fn is_empty(&self) -> bool
1.9.0
Checks whether the OsStr
is empty.
fn len(&self) -> usize
1.9.0
Returns the length of this OsStr
.
Note that this does not return the number of bytes in this string
as, for example, OS strings on Windows are encoded as a list of u16
rather than a list of bytes. This number is simply useful for passing to
other methods like OsString::with_capacity
to avoid reallocations.
See OsStr
introduction for more information about encoding.