Struct mmtkvdb::Owned

source ·
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,

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§

fn as_ref(&self) -> &U

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<B> Borrow<B> for Owned<B>where B: ToOwned + ?Sized,

source§

fn borrow(&self) -> &B

Immutably borrows from an owned value. Read more
source§

impl<B> Clone for Owned<B>where B: ToOwned + ?Sized, <B as ToOwned>::Owned: Clone,

source§

fn clone(&self) -> Owned<B>

Returns a copy of the value. Read more
source§

fn clone_from(&mut self, source: &Owned<B>)

Performs copy-assignment from source. Read more
source§

impl<B> Debug for Owned<B>where B: Debug + ToOwned + ?Sized, <B as ToOwned>::Owned: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<B> Default for Owned<B>where B: ToOwned + ?Sized, <B as ToOwned>::Owned: Default,

source§

fn default() -> Owned<B>

Returns the “default value” for a type. Read more
source§

impl<B> Deref for Owned<B>where B: ToOwned + ?Sized,

§

type Target = B

The resulting type after dereferencing.
source§

fn deref(&self) -> &B

Dereferences the value.
source§

impl<B> Display for Owned<B>where B: Display + ToOwned + ?Sized, <B as ToOwned>::Owned: Display,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<B> GenericCow for Owned<B>where B: ToOwned + ?Sized,

§

type Borrowed = B

Borrowed type Read more
source§

fn into_owned(self) -> <B as ToOwned>::Owned

Convert into owned type Read more
source§

impl<B> Hash for Owned<B>where B: ToOwned + ?Sized, <B as ToOwned>::Owned: Hash,

source§

fn hash<H>(&self, state: &mut H)where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<B> Ord for Owned<B>where B: ToOwned + ?Sized, <B as ToOwned>::Owned: Ord,

source§

fn cmp(&self, other: &Owned<B>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
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>,

source§

fn eq(&self, other: &Owned<C>) -> bool

This method tests for self and other values to be equal, and is used by ==.
source§

fn ne(&self, other: &Owned<C>) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
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>,

source§

fn partial_cmp(&self, other: &Owned<C>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
source§

fn lt(&self, other: &Owned<C>) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
source§

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
source§

fn gt(&self, other: &Owned<C>) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
source§

fn ge(&self, other: &Owned<C>) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> Env for Twhere T: AsRef<EnvRo>,

source§

fn clone_ro(&self) -> EnvRo

Clone as EnvRo
source§

fn txn_ro(&self) -> Result<TxnRo<'_>, Error>

Start read-only transaction
source§

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>,

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,

Open databases in environment Read more
source§

unsafe fn open_db<K, V, C>( &self, options: &DbBuilder<K, V, C, Option<CString>> ) -> Result<Db<K, V, C>, Error>where K: Storable + ?Sized, V: Storable + ?Sized, C: Constraint,

Open database in environment Read more
source§

fn clear_stale_readers(&self) -> Result<(), Error>

Clear stale readers Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.