pub struct Cow<'a, T: Beef + ?Sized + 'a, U: Capacity> { /* fields omitted */ }
Expand description
impl<T: ?Sized, U> Cow<'_, T, U> where
T: Beef,
U: Capacity,
Owned data.
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,
Borrowed data.
use beef::Cow;
let borrowed: Cow<str> = Cow::borrowed("I'm just a borrow");
Extracts the owned data.
Clones the data if it is not already owned.
Extracts borrowed data.
Panics: If the data is owned.
Returns true
if data is borrowed or had no capacity.
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);
Returns true
if data is owned and has non-0 capacity.
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>
Borrowed data.
This is functionally identical to borrow
.
We use impl specialization to allow this function to be const
.
use beef::Cow;
const HELLO: Cow<str> = Cow::const_str("Hello");
impl<'a> Cow<'a, str, Lean>
Borrowed data.
This is functionally identical to borrow
.
We use impl specialization to allow this function to be const
.
use beef::lean::Cow;
const HELLO: Cow<str> = Cow::const_str("Hello");
impl<T: ?Sized, U> AsRef<T> for Cow<'_, T, U> where
T: Beef,
U: Capacity,
impl<T: ?Sized, U> Borrow<T> for Cow<'_, T, U> where
T: Beef,
U: Capacity,
Immutably borrows from an owned value. Read more
impl<'a, T: ?Sized, U> Clone for Cow<'a, T, U> where
T: Beef,
U: Capacity,
Performs copy-assignment from source
. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
impl<T: ?Sized, U> Deref for Cow<'_, T, U> where
T: Beef,
U: Capacity,
The resulting type after dereferencing.
Formats the value using the given formatter. Read more
impl<T: ?Sized, U> Drop for Cow<'_, T, U> where
T: Beef,
U: Capacity,
Executes the destructor for this type. Read more
impl<'a, T: ?Sized, U> From<&'a T> for Cow<'a, T, U> where
T: Beef,
U: Capacity,
fn from(val: &'a T) -> Self
fn from(cow: Cow<'a, T, U>) -> Self
impl<'a, T: ?Sized, U> From<Cow<'a, T>> for Cow<'a, T, U> where
T: Beef,
U: Capacity,
impl<T: ?Sized, U> Ord for Cow<'_, T, U> where
T: Ord + Beef,
U: Capacity,
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
fn clamp(self, min: Self, max: Self) -> Self
Restrict a value to a certain interval. Read more
fn eq(&self, other: &&[T]) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl<U> PartialEq<&'_ str> for Cow<'_, str, U> where
U: Capacity,
fn eq(&self, other: &&str) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
fn eq(&self, other: &[T]) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
fn eq(&self, other: &Cow<'_, [T], U>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
fn eq(&self, other: &Cow<'_, [T], U>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
fn eq(&self, other: &Cow<'_, [T], U>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
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>,
fn eq(&self, other: &Cow<'_, B, V>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl<U> PartialEq<Cow<'_, str, U>> for str where
U: Capacity,
fn eq(&self, other: &Cow<'_, str, U>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl<U> PartialEq<Cow<'_, str, U>> for &str where
U: Capacity,
fn eq(&self, other: &Cow<'_, str, U>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
fn eq(&self, other: &Cow<'_, str, U>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
fn eq(&self, other: &Vec<T>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl<U> PartialEq<str> for Cow<'_, str, U> where
U: Capacity,
fn eq(&self, other: &str) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
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,
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<T: ?Sized, U> Eq for Cow<'_, T, U> where
T: Eq + Beef,
U: Capacity,
impl<T> Any for T where
T: 'static + ?Sized,
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
impl<T, U> Into<U> for T where
U: From<T>,
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String
. Read more
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.