[−][src]Struct pstr::ffi::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]
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]
s: S,
to_arc: impl FnOnce(S) -> Arc<OsStr>
) -> Self
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
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.
fn add(self, rhs: T) -> Self::Output
[src]
impl<T: AsRef<OsStr>> AddAssign<T> for MowOsStr
[src]
fn add_assign(&mut self, rhs: T)
[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]
fn borrow_mut(&mut self) -> &mut OsStr
[src]
impl Clone for MowOsStr
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for MowOsStr
[src]
impl Deref for MowOsStr
[src]
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]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for MowOsStr
[src]
fn cmp(&self, other: &MowOsStr) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[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]
fn partial_cmp(&self, other: &MowOsStr) -> Option<Ordering>
[src]
fn lt(&self, other: &MowOsStr) -> bool
[src]
fn le(&self, other: &MowOsStr) -> bool
[src]
fn gt(&self, other: &MowOsStr) -> bool
[src]
fn ge(&self, other: &MowOsStr) -> bool
[src]
impl StructuralEq for MowOsStr
[src]
impl StructuralPartialEq for MowOsStr
[src]
Auto Trait Implementations
impl RefUnwindSafe for MowOsStr
impl Send for MowOsStr
impl Sync for MowOsStr
impl Unpin for MowOsStr
impl UnwindSafe for MowOsStr
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,