pub struct Owned<B>(pub <B as ToOwned>::Owned)
where
B: ToOwned + ?Sized;
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§
source§impl<B, U> AsRef<U> for Owned<B>where
B: ToOwned + ?Sized,
<B as ToOwned>::Owned: AsRef<U>,
U: ?Sized,
impl<B, U> AsRef<U> for Owned<B>where B: ToOwned + ?Sized, <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
.
source§impl<B> Display for Owned<B>where
B: Display + ToOwned + ?Sized,
<B as ToOwned>::Owned: Display,
impl<B> Display for Owned<B>where B: Display + ToOwned + ?Sized, <B as ToOwned>::Owned: Display,
source§impl<B> Ord for Owned<B>where
B: ToOwned + ?Sized,
<B as ToOwned>::Owned: Ord,
impl<B> Ord for Owned<B>where B: ToOwned + ?Sized, <B as ToOwned>::Owned: Ord,
source§impl<B, C> PartialEq<Owned<C>> for Owned<B>where
B: ToOwned + ?Sized,
C: ToOwned + ?Sized,
<B as ToOwned>::Owned: PartialEq<<C as ToOwned>::Owned>,
impl<B, C> PartialEq<Owned<C>> for Owned<B>where B: ToOwned + ?Sized, C: ToOwned + ?Sized, <B as ToOwned>::Owned: PartialEq<<C as ToOwned>::Owned>,
source§impl<B, C> PartialOrd<Owned<C>> for Owned<B>where
B: ToOwned + ?Sized,
C: ToOwned + ?Sized,
<B as ToOwned>::Owned: PartialOrd<<C as ToOwned>::Owned>,
impl<B, C> PartialOrd<Owned<C>> for Owned<B>where B: ToOwned + ?Sized, C: ToOwned + ?Sized, <B as ToOwned>::Owned: PartialOrd<<C as ToOwned>::Owned>,
source§fn 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 moreimpl<B> Eq for Owned<B>where B: ToOwned + ?Sized, <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§
source§impl<T> Env for Twhere
T: AsRef<EnvRo>,
impl<T> Env for Twhere T: AsRef<EnvRo>,
source§fn max_keysize(&self) -> usize
fn max_keysize(&self) -> usize
Get maximum size of keys and duplicate data
source§fn valid_keysize<'kr, K, KRef>(&self, key: KRef) -> boolwhere
K: Storable + 'kr + ?Sized,
KRef: StorableRef<'kr, K>,
fn valid_keysize<'kr, K, KRef>(&self, key: KRef) -> boolwhere K: Storable + 'kr + ?Sized, KRef: StorableRef<'kr, K>,
Checks if key or duplicate data has valid size
source§unsafe fn open_dbs<'a, K, V, C>(
&self,
options: impl IntoIterator<IntoIter = impl Iterator<Item = &'a DbBuilder<K, V, C, Option<CString>>> + ExactSizeIterator>
) -> Result<Vec<Db<K, V, C>, Global>, Error>where
K: Storable + 'a + ?Sized,
V: Storable + 'a + ?Sized,
C: Constraint,
unsafe fn open_dbs<'a, K, V, C>( &self, options: impl IntoIterator<IntoIter = impl Iterator<Item = &'a DbBuilder<K, V, C, Option<CString>>> + ExactSizeIterator> ) -> Result<Vec<Db<K, V, C>, Global>, Error>where K: Storable + 'a + ?Sized, V: Storable + 'a + ?Sized, C: Constraint,
Open databases in environment Read more