[−][src]Struct beef::generic::Cow
A clone-on-write smart pointer, mostly compatible with std::borrow::Cow
.
This type is using a generic U: Capacity
. Use either beef::Cow
or beef::lean::Cow
in your code.
Implementations
impl<T: ?Sized, U, '_> Cow<'_, T, U> where
T: Beef,
U: Capacity,
[src]
T: Beef,
U: Capacity,
pub fn owned(val: T::Owned) -> Self
[src]
Owned data.
Example
use beef::Cow; let owned: Cow<str> = Cow::owned("I own my content".to_string());
impl<'a, T: ?Sized, U> Cow<'a, T, U> where
T: Beef,
U: Capacity,
[src]
T: Beef,
U: Capacity,
pub fn borrowed(val: &'a T) -> Self
[src]
pub fn into_owned(self) -> T::Owned
[src]
Extracts the owned data.
Clones the data if it is not already owned.
pub fn unwrap_borrowed(self) -> &'a T
[src]
Extracts borrowed data.
Panics: If the data is owned.
pub fn is_borrowed(&self) -> bool
[src]
Returns true
if data is borrowed or had no capacity.
Example
use beef::Cow; let borrowed: Cow<str> = Cow::borrowed("Borrowed"); let no_capacity: Cow<str> = Cow::owned(String::new()); let owned: Cow<str> = Cow::owned(String::from("Owned")); assert_eq!(borrowed.is_borrowed(), true); assert_eq!(no_capacity.is_borrowed(), true); assert_eq!(owned.is_borrowed(), false);
pub fn is_owned(&self) -> bool
[src]
Returns true
if data is owned and has non-0 capacity.
Example
use beef::Cow; let borrowed: Cow<str> = Cow::borrowed("Borrowed"); let no_capacity: Cow<str> = Cow::owned(String::new()); let owned: Cow<str> = Cow::owned(String::from("Owned")); assert_eq!(borrowed.is_owned(), false); assert_eq!(no_capacity.is_owned(), false); assert_eq!(owned.is_owned(), true);
impl<'a> Cow<'a, str, Wide>
[src]
impl<'a> Cow<'a, str, Lean>
[src]
Trait Implementations
impl<T: ?Sized, U, '_> AsRef<T> for Cow<'_, T, U> where
T: Beef,
U: Capacity,
[src]
T: Beef,
U: Capacity,
impl<T: ?Sized, U, '_> Borrow<T> for Cow<'_, T, U> where
T: Beef,
U: Capacity,
[src]
T: Beef,
U: Capacity,
impl<'a, T: ?Sized, U> Clone for Cow<'a, T, U> where
T: Beef,
U: Capacity,
[src]
T: Beef,
U: Capacity,
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: ?Sized, U, '_> Debug for Cow<'_, T, U> where
T: Beef + Debug,
U: Capacity,
[src]
T: Beef + Debug,
U: Capacity,
impl<'a, T: ?Sized, U> Default for Cow<'a, T, U> where
T: Beef,
U: Capacity,
&'a T: Default,
[src]
T: Beef,
U: Capacity,
&'a T: Default,
impl<T: ?Sized, U, '_> Deref for Cow<'_, T, U> where
T: Beef,
U: Capacity,
[src]
T: Beef,
U: Capacity,
impl<T: ?Sized, U, '_> Display for Cow<'_, T, U> where
T: Beef + Display,
U: Capacity,
[src]
T: Beef + Display,
U: Capacity,
impl<T: ?Sized, U, '_> Drop for Cow<'_, T, U> where
T: Beef,
U: Capacity,
[src]
T: Beef,
U: Capacity,
impl<T: ?Sized, U, '_> Eq for Cow<'_, T, U> where
T: Eq + Beef,
U: Capacity,
[src]
T: Eq + Beef,
U: Capacity,
impl<'a, T: ?Sized, U> From<&'a T> for Cow<'a, T, U> where
T: Beef,
U: Capacity,
[src]
T: Beef,
U: Capacity,
impl<'a, T: ?Sized, U> From<Cow<'a, T, U>> for StdCow<'a, T> where
T: Beef,
U: Capacity,
[src]
T: Beef,
U: Capacity,
impl<'a, T: ?Sized, U> From<Cow<'a, T>> for Cow<'a, T, U> where
T: Beef,
U: Capacity,
[src]
T: Beef,
U: Capacity,
impl<U, '_> From<String> for Cow<'_, str, U> where
U: Capacity,
[src]
U: Capacity,
impl<T, U, '_> From<Vec<T>> for Cow<'_, [T], U> where
T: Clone,
U: Capacity,
[src]
T: Clone,
U: Capacity,
impl<T: ?Sized, U, '_> Hash for Cow<'_, T, U> where
T: Hash + Beef,
U: Capacity,
[src]
T: Hash + Beef,
U: Capacity,
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<T: ?Sized, U, '_> Ord for Cow<'_, T, U> where
T: Ord + Beef,
U: Capacity,
[src]
T: Ord + Beef,
U: Capacity,
fn cmp(&self, other: &Self) -> 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<U, T, '_, '_> PartialEq<&'_ [T]> for Cow<'_, [T], U> where
U: Capacity,
T: Clone + PartialEq,
[src]
U: Capacity,
T: Clone + PartialEq,
impl<U, '_, '_> PartialEq<&'_ str> for Cow<'_, str, U> where
U: Capacity,
[src]
U: Capacity,
impl<U, T, '_> PartialEq<[T]> for Cow<'_, [T], U> where
U: Capacity,
T: Clone + PartialEq,
[src]
U: Capacity,
T: Clone + PartialEq,
impl<U, T, '_> PartialEq<Cow<'_, [T], U>> for [T] where
U: Capacity,
T: Clone + PartialEq,
[src]
U: Capacity,
T: Clone + PartialEq,
fn eq(&self, other: &Cow<'_, [T], U>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<U, T, '_, '_> PartialEq<Cow<'_, [T], U>> for &'_ [T] where
U: Capacity,
T: Clone + PartialEq,
[src]
U: Capacity,
T: Clone + PartialEq,
fn eq(&self, other: &Cow<'_, [T], U>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<U, T, '_> PartialEq<Cow<'_, [T], U>> for Vec<T> where
U: Capacity,
T: Clone + PartialEq,
[src]
U: Capacity,
T: Clone + PartialEq,
fn eq(&self, other: &Cow<'_, [T], U>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<A: ?Sized, B: ?Sized, U, V, '_, '_> PartialEq<Cow<'_, B, V>> for Cow<'_, A, U> where
A: Beef,
B: Beef,
U: Capacity,
V: Capacity,
A: PartialEq<B>,
[src]
A: Beef,
B: Beef,
U: Capacity,
V: Capacity,
A: PartialEq<B>,
fn eq(&self, other: &Cow<'_, B, V>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<U, '_> PartialEq<Cow<'_, str, U>> for str where
U: Capacity,
[src]
U: Capacity,
fn eq(&self, other: &Cow<'_, str, U>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<U, '_, '_> PartialEq<Cow<'_, str, U>> for &'_ str where
U: Capacity,
[src]
U: Capacity,
fn eq(&self, other: &Cow<'_, str, U>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<U, '_> PartialEq<Cow<'_, str, U>> for String where
U: Capacity,
[src]
U: Capacity,
fn eq(&self, other: &Cow<'_, str, U>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<U, '_> PartialEq<String> for Cow<'_, str, U> where
U: Capacity,
[src]
U: Capacity,
impl<U, T, '_> PartialEq<Vec<T>> for Cow<'_, [T], U> where
U: Capacity,
T: Clone + PartialEq,
[src]
U: Capacity,
T: Clone + PartialEq,
impl<U, '_> PartialEq<str> for Cow<'_, str, U> where
U: Capacity,
[src]
U: Capacity,
impl<A: ?Sized, B: ?Sized, U, V, '_, '_> PartialOrd<Cow<'_, B, V>> for Cow<'_, A, U> where
A: Beef + PartialOrd<B>,
B: Beef,
U: Capacity,
V: Capacity,
[src]
A: Beef + PartialOrd<B>,
B: Beef,
U: Capacity,
V: Capacity,
fn partial_cmp(&self, other: &Cow<'_, B, V>) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<T: Beef + Send + ?Sized, U: Capacity, '_> Send for Cow<'_, T, U>
[src]
impl<T: Beef + Sync + ?Sized, U: Capacity, '_> Sync for Cow<'_, T, U>
[src]
Auto Trait Implementations
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> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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>,