[][src]Struct pstr::ffi::MowOsStr

pub struct MowOsStr(_);

Mutable on Write Interning OsString

It will be auto switch to mutable when do modify operate

Can call .intern() to save into intern pool

Example

let mut s = MowOsStr::new("hello");
assert!(s.is_interned());

s.push(" ");
assert!(s.is_mutable());

s.mutdown().push("world");
assert_eq!(s, "hello world");

s.intern();
assert!(s.is_interned());

Implementations

impl MowOsStr[src]

pub fn new(s: impl AsRef<OsStr>) -> Self[src]

Create a MowOsStr from OsStr slice

Example

let s = MowOsStr::new("hello world");

pub fn new_mut(s: impl Into<OsString>) -> Self[src]

Create a MowOsStr from OsStr slice with mutable

Example

let s = MowOsStr::new_mut("hello world");
assert!(s.is_mutable());

pub fn mut_empty() -> Self[src]

Create a new empty MowOsStr with mutable

Example

let s = MowOsStr::mut_empty();
assert!(s.is_mutable());

pub fn mut_with_capacity(capacity: usize) -> Self[src]

Create a new empty MowOsStr with a particular capacity and mutable

pub fn from_os_string(s: OsString) -> Self[src]

Create a MowOsStr from String

pub fn from_os_string_mut(s: OsString) -> Self[src]

Create a MowOsStr from String with mutable

pub fn from_boxed(s: Box<OsStr>) -> Self[src]

Create a MowOsStr from Box<OsStr>

pub fn from_arc(s: Arc<OsStr>) -> Self[src]

Create a MowOsStr from Arc<OsStr>

pub fn from_rc(s: Rc<OsStr>) -> Self[src]

Create a MowOsStr from Rc<OsStr>

pub fn from_i_os_str(s: IOsStr) -> Self[src]

Create a MowOsStr from IOsStr

pub fn from_to_arc<S: AsRef<OsStr>>(
    s: S,
    to_arc: impl FnOnce(S) -> Arc<OsStr>
) -> Self
[src]

Create a MowOsStr from custom fn

impl MowOsStr[src]

pub fn intern(&mut self)[src]

Save the current state to the intern pool
Do nothing if already in the pool

pub fn to_mut(&mut self)[src]

Get a mutable clone of the string on the pool
Do nothing if already mutable

pub fn mutdown(&mut self) -> &mut OsString[src]

Switch to mutable and return a mutable reference

pub fn to_mut_by(&mut self, f: impl FnOnce(&mut IOsStr) -> OsString)[src]

Do nothing if already mutable

pub fn swap_mut(&mut self, s: OsString) -> Option<OsString>[src]

Swap internal OsString
Return None if self is interned

pub fn try_swap_mut(&mut self, s: OsString) -> Option<OsString>[src]

Swap internal OsString when self is mutable
Do nothing if self is interned
Return None if self is interned

pub fn is_interned(&self) -> bool[src]

Check if it is in intern pool

pub fn is_mutable(&self) -> bool[src]

Check if it is mutable

pub fn try_istr(&self) -> Option<&IOsStr>[src]

Try get IOsStr

pub fn try_string(&self) -> Option<&OsString>[src]

Try get OsString

pub fn into_i_os_str(&self) -> IOsStr[src]

Make a IStr

impl MowOsStr[src]

pub fn ref_os_str(&self) -> &OsStr[src]

Get &str

pub fn mut_os_str(&mut self) -> &mut OsStr[src]

Get &mut str

pub fn mut_os_string(&mut self) -> &mut OsString[src]

Get &mut String

pub fn as_os_str(&self) -> &OsStr[src]

Extracts a string slice containing the entire MowStr

pub fn as_mut_os_str(&mut self) -> &mut OsStr[src]

Switch to mutable and returns a mutable string slice.

pub fn as_mut_os_string(&mut self) -> &mut OsString[src]

Switch to mutable and returns a mutable String reference

pub fn into_os_string(self) -> OsString[src]

Convert to String

pub fn into_boxed_os_str(self) -> Box<OsStr>[src]

Convert to Box<str>

impl MowOsStr[src]

pub fn push(&mut self, s: impl AsRef<OsStr>)[src]

Extends the string with the given &OsStr slice.

pub fn clear(&mut self)[src]

Truncates the MowOsStr to zero length.

pub fn reserve(&mut self, additional: usize)[src]

Reserves capacity for at least additional more capacity to be inserted in the given MowOsStr.

pub fn reserve_exact(&mut self, additional: usize)[src]

Reserves the minimum capacity for exactly additional more capacity to be inserted in the given MowOsStr. Does nothing if the capacity is already sufficient.

pub fn shrink_to_fit(&mut self)[src]

Shrinks the capacity of the MowOsStr to match its length.

Trait Implementations

impl<T: AsRef<OsStr>> Add<T> for MowOsStr[src]

type Output = MowOsStr

The resulting type after applying the + operator.

impl<T: AsRef<OsStr>> AddAssign<T> for MowOsStr[src]

impl AsMut<OsStr> for MowOsStr[src]

impl AsMut<OsString> for MowOsStr[src]

impl AsRef<OsStr> for MowOsStr[src]

impl AsRef<Path> for MowOsStr[src]

impl Borrow<OsStr> for MowOsStr[src]

impl BorrowMut<OsStr> for MowOsStr[src]

impl Clone for MowOsStr[src]

impl Debug for MowOsStr[src]

impl Deref for MowOsStr[src]

type Target = OsStr

The resulting type after dereferencing.

impl DerefMut for MowOsStr[src]

impl Eq for MowOsStr[src]

impl<'_> From<&'_ OsStr> for MowOsStr[src]

impl<'_> From<&'_ OsString> for MowOsStr[src]

impl<'_> From<&'_ mut OsStr> for MowOsStr[src]

impl From<Arc<OsStr>> for MowOsStr[src]

impl From<Box<OsStr>> for MowOsStr[src]

impl From<IOsStr> for MowOsStr[src]

impl From<MowOsStr> for OsString[src]

impl From<MowOsStr> for Box<OsStr>[src]

impl From<MowOsStr> for Arc<OsStr>[src]

impl From<MowOsStr> for IOsStr[src]

impl From<OsString> for MowOsStr[src]

impl From<PathBuf> for MowOsStr[src]

impl From<Rc<OsStr>> for MowOsStr[src]

impl Hash for MowOsStr[src]

impl Interning for MowOsStr[src]

type Outern = MowOsStr

impl Muterning for MowOsStr[src]

type Outern = MowOsStr

impl Ord for MowOsStr[src]

impl<'_> PartialEq<&'_ OsStr> for MowOsStr[src]

impl<'_> PartialEq<&'_ str> for MowOsStr[src]

impl PartialEq<MowOsStr> for MowOsStr[src]

impl PartialEq<OsStr> for MowOsStr[src]

impl PartialEq<OsString> for MowOsStr[src]

impl PartialEq<String> for MowOsStr[src]

impl PartialEq<str> for MowOsStr[src]

impl PartialOrd<MowOsStr> for MowOsStr[src]

impl StructuralEq for MowOsStr[src]

impl StructuralPartialEq for MowOsStr[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.