Struct std::ffi::OsStr
[−]
[src]
pub struct OsStr {
// some fields omitted
}1.0.0Slices 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.
1.9.0fn is_empty(&self) -> bool
Checks whether the OsStr is empty.
1.9.0fn len(&self) -> usize
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.