pub struct OsStr { /* fields omitted */ }
Borrowed reference to an OS string (see OsString
).
This type represents a borrowed reference to a string in the operating system's preferred
representation.
&OsStr
is to OsString
as &str
is to String
: the former in each pair are borrowed
references; the latter are owned strings.
See the module's toplevel documentation about conversions for a discussion on
the traits which OsStr
implements for conversions from/to native representations.
Coerces into an OsStr
slice.
use std::ffi::OsStr;
let os_str = OsStr::new("foo");Run
Yields a &str
slice if the OsStr
is valid Unicode.
This conversion may entail doing a check for UTF-8 validity.
use std::ffi::OsStr;
let os_str = OsStr::new("foo");
assert_eq!(os_str.to_str(), Some("foo"));Run
Converts an OsStr
to a Cow
<
str
>
.
Any non-Unicode sequences are replaced with U+FFFD REPLACEMENT CHARACTER.
Calling to_string_lossy
on an OsStr
with valid unicode:
use std::ffi::OsStr;
let os_str = OsStr::new("foo");
assert_eq!(os_str.to_string_lossy(), "foo");Run
Had os_str
contained invalid unicode, the to_string_lossy
call might
have returned "fo�"
.
Copies the slice into an owned OsString
.
use std::ffi::{OsStr, OsString};
let os_str = OsStr::new("foo");
let os_string = os_str.to_os_string();
assert_eq!(os_string, OsString::from("foo"));Run
Checks whether the OsStr
is empty.
use std::ffi::OsStr;
let os_str = OsStr::new("");
assert!(os_str.is_empty());
let os_str = OsStr::new("foo");
assert!(!os_str.is_empty());Run
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.
use std::ffi::OsStr;
let os_str = OsStr::new("");
assert_eq!(os_str.len(), 0);
let os_str = OsStr::new("foo");
assert_eq!(os_str.len(), 3);Run
Converts a Box
<OsStr>
into an OsString
without copying or allocating.
[+]
[+]
[+]
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method returns an ordering between self
and other
values if one exists. Read more
[−]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
[−]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
[−]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
[−]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
[+]
[−]
This method returns an ordering between self
and other
values if one exists. Read more
[−]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
[−]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
[−]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
[−]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
[+]
[−]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self | 1.21.0 [src] |
[−]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self | 1.21.0 [src] |
[−]
Compares and returns the minimum of two values. Read more
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method returns an ordering between self
and other
values if one exists. Read more
[−]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
[−]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
[−]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
[−]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
[+]
[−]
This method returns an ordering between self
and other
values if one exists. Read more
[−]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
[−]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
[−]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
[−]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method returns an ordering between self
and other
values if one exists. Read more
[−]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
[−]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
[−]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
[−]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
[+]
[−]
This method returns an ordering between self
and other
values if one exists. Read more
[−]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
[−]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
[−]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
[−]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method returns an ordering between self
and other
values if one exists. Read more
[−]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
[−]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
[−]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
[−]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
[+]
[−]
This method returns an ordering between self
and other
values if one exists. Read more
[−]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
[−]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
[−]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
[−]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method returns an ordering between self
and other
values if one exists. Read more
[−]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
[−]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
[−]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
[−]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
[+]
[−]
This method returns an ordering between self
and other
values if one exists. Read more
[−]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
[−]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
[−]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
[−]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
[+]
[+]
[+]
[+]
type Owned = OsString
[−]
Creates owned data from borrowed data, usually by cloning. Read more
[−]
🔬 This is a nightly-only experimental API. (toowned_clone_into
#41263)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
[+]
[+]
[+]
[+]
[+]
[+]
[+]
[+]
[+]
[+]
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method returns an ordering between self
and other
values if one exists. Read more
[−]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
[−]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
[−]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
[−]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
[+]
[−]
This method returns an ordering between self
and other
values if one exists. Read more
[−]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
[−]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
[−]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
[−]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method returns an ordering between self
and other
values if one exists. Read more
[−]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
[−]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
[−]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
[−]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
[+]
[−]
This method returns an ordering between self
and other
values if one exists. Read more
[−]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
[−]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
[−]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
[−]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method returns an ordering between self
and other
values if one exists. Read more
[−]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
[−]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
[−]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
[−]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
[+]
[−]
This method returns an ordering between self
and other
values if one exists. Read more
[−]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
[−]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
[−]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
[−]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method returns an ordering between self
and other
values if one exists. Read more
[−]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
[−]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
[−]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
[−]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
[+]
[−]
This method returns an ordering between self
and other
values if one exists. Read more
[−]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
[−]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
[−]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
[−]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method returns an ordering between self
and other
values if one exists. Read more
[−]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
[−]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
[−]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
[−]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
[+]
[−]
This method returns an ordering between self
and other
values if one exists. Read more
[−]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
[−]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
[−]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
[−]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method returns an ordering between self
and other
values if one exists. Read more
[−]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
[−]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
[−]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
[−]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
[+]
[−]
This method returns an ordering between self
and other
values if one exists. Read more
[−]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
[−]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
[−]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
[−]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
[+]
[−]
This method returns an ordering between self
and other
values if one exists. Read more
[−]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
[−]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
[−]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
[−]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
[+]
[−]
This method returns an ordering between self
and other
values if one exists. Read more
[−]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
[−]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
[−]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
[−]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
[+]
[−]
This is supported on Unix only.
Creates an [OsStr
] from a byte slice. Read more
[−]
This is supported on Unix only.
Gets the underlying byte view of the [OsStr
] slice. Read more
[+]
[−]
This is supported on Windows only.
Re-encodes an OsStr
as a wide character sequence, i.e. potentially ill-formed UTF-16. Read more