Struct deref_owned::Owned
source · [−]Expand description
Wrapper akin to Cow::Owned
but known to be owned at compile-time
The wrapper takes a type argument B
and a value of type
<B as ToOwned>::Owned
.
It supports dereference (with B
being the target),
implements Borrow<B>
, and
GenericCow<Borrowed = B>
.
Example
use deref_owned::{GenericCow, Owned};
use std::borrow::Cow;
fn generic_fn(arg: impl GenericCow<Borrowed = str>) { /* ... */ }
generic_fn(Owned("Hello".to_string()));
generic_fn(Cow::Owned("Hello".to_string()));
generic_fn(Cow::Borrowed("Hello"));
generic_fn("Hello");
Tuple Fields
0: <B as ToOwned>::Owned
Trait Implementations
sourceimpl<B, U> AsRef<U> for Owned<B> where
B: ?Sized + ToOwned,
<B as ToOwned>::Owned: AsRef<U>,
U: ?Sized,
impl<B, U> AsRef<U> for Owned<B> where
B: ?Sized + ToOwned,
<B as ToOwned>::Owned: AsRef<U>,
U: ?Sized,
AsRef
is only implemented when the inner type implements
AsRef
. This is consistent with the blanket implementation of AsRef
for
shared references but not consistent with Cow
’s
implementation of AsRef
.
sourceimpl<B: Display> Display for Owned<B> where
B: ?Sized + ToOwned,
<B as ToOwned>::Owned: Display,
impl<B: Display> Display for Owned<B> where
B: ?Sized + ToOwned,
<B as ToOwned>::Owned: Display,
sourceimpl<B> GenericCow for Owned<B> where
B: ?Sized + ToOwned,
impl<B> GenericCow for Owned<B> where
B: ?Sized + ToOwned,
sourceimpl<B> Ord for Owned<B> where
B: ?Sized + ToOwned,
<B as ToOwned>::Owned: Ord,
impl<B> Ord for Owned<B> where
B: ?Sized + ToOwned,
<B as ToOwned>::Owned: Ord,
sourceimpl<B, C> PartialEq<Owned<C>> for Owned<B> where
B: ?Sized + ToOwned,
C: ?Sized + ToOwned,
<B as ToOwned>::Owned: PartialEq<<C as ToOwned>::Owned>,
impl<B, C> PartialEq<Owned<C>> for Owned<B> where
B: ?Sized + ToOwned,
C: ?Sized + ToOwned,
<B as ToOwned>::Owned: PartialEq<<C as ToOwned>::Owned>,
sourceimpl<B, C> PartialOrd<Owned<C>> for Owned<B> where
B: ?Sized + ToOwned,
C: ?Sized + ToOwned,
<B as ToOwned>::Owned: PartialOrd<<C as ToOwned>::Owned>,
impl<B, C> PartialOrd<Owned<C>> for Owned<B> where
B: ?Sized + ToOwned,
C: ?Sized + ToOwned,
<B as ToOwned>::Owned: PartialOrd<<C as ToOwned>::Owned>,
sourcefn partial_cmp(&self, other: &Owned<C>) -> Option<Ordering>
fn partial_cmp(&self, other: &Owned<C>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
sourcefn lt(&self, other: &Owned<C>) -> bool
fn lt(&self, other: &Owned<C>) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
sourcefn le(&self, other: &Owned<C>) -> bool
fn le(&self, other: &Owned<C>) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<B> Eq for Owned<B> where
B: ?Sized + ToOwned,
<B as ToOwned>::Owned: Eq,
Auto Trait Implementations
impl<B: ?Sized> RefUnwindSafe for Owned<B> where
<B as ToOwned>::Owned: RefUnwindSafe,
impl<B: ?Sized> Send for Owned<B> where
<B as ToOwned>::Owned: Send,
impl<B: ?Sized> Sync for Owned<B> where
<B as ToOwned>::Owned: Sync,
impl<B: ?Sized> Unpin for Owned<B> where
<B as ToOwned>::Owned: Unpin,
impl<B: ?Sized> UnwindSafe for Owned<B> where
<B as ToOwned>::Owned: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more