Trait RawOsStrCow

Source
pub trait RawOsStrCow<'a>: Sealed {
    // Required methods
    fn from_os_str(string: Cow<'a, OsStr>) -> Self;
    fn into_os_str(self) -> Cow<'a, OsStr>;
}
Expand description

Extensions to Cow<RawOsStr> for additional conversions.

Required Methods§

Source

fn from_os_str(string: Cow<'a, OsStr>) -> Self

Converts a platform-native string back to this representation, without copying or encoding conversion.

§Examples
use std::borrow::Cow;
use std::env;

use os_str_bytes::RawOsStr;
use os_str_bytes::RawOsStrCow;

let os_string = Cow::Owned(env::current_exe()?.into_os_string());
println!("{:?}", Cow::from_os_str(os_string));
Source

fn into_os_str(self) -> Cow<'a, OsStr>

Converts this representation back to a platform-native string, without copying or encoding conversion.

§Examples
use std::borrow::Cow;
use std::env;

use os_str_bytes::RawOsStr;
use os_str_bytes::RawOsStrCow;

let os_string = env::current_exe()?.into_os_string();
let raw = Cow::Borrowed(RawOsStr::new(&os_string));
assert_eq!(os_string, raw.into_os_str());

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'a> RawOsStrCow<'a> for Cow<'a, RawOsStr>

Source§

fn from_os_str(string: Cow<'a, OsStr>) -> Self

Available on crate feature raw_os_str only.
Source§

fn into_os_str(self) -> Cow<'a, OsStr>

Available on crate feature raw_os_str only.

Implementors§