diff options
Diffstat (limited to 'ctr-std/src/ffi/os_str.rs')
| -rw-r--r-- | ctr-std/src/ffi/os_str.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/ctr-std/src/ffi/os_str.rs b/ctr-std/src/ffi/os_str.rs index 4850ed0..0a31480 100644 --- a/ctr-std/src/ffi/os_str.rs +++ b/ctr-std/src/ffi/os_str.rs @@ -664,6 +664,38 @@ impl<'a> From<&'a OsStr> for Rc<OsStr> { } } +#[stable(feature = "cow_from_osstr", since = "1.28.0")] +impl<'a> From<OsString> for Cow<'a, OsStr> { + #[inline] + fn from(s: OsString) -> Cow<'a, OsStr> { + Cow::Owned(s) + } +} + +#[stable(feature = "cow_from_osstr", since = "1.28.0")] +impl<'a> From<&'a OsStr> for Cow<'a, OsStr> { + #[inline] + fn from(s: &'a OsStr) -> Cow<'a, OsStr> { + Cow::Borrowed(s) + } +} + +#[stable(feature = "cow_from_osstr", since = "1.28.0")] +impl<'a> From<&'a OsString> for Cow<'a, OsStr> { + #[inline] + fn from(s: &'a OsString) -> Cow<'a, OsStr> { + Cow::Borrowed(s.as_os_str()) + } +} + +#[stable(feature = "osstring_from_cow_osstr", since = "1.28.0")] +impl<'a> From<Cow<'a, OsStr>> for OsString { + #[inline] + fn from(s: Cow<'a, OsStr>) -> Self { + s.into_owned() + } +} + #[stable(feature = "box_default_extra", since = "1.17.0")] impl Default for Box<OsStr> { fn default() -> Box<OsStr> { |