pub enum MaybeOwned<'a, TOwned, TBorrowed: ?Sized = TOwned> {
Owned(TOwned),
Borrowed(&'a TBorrowed),
}Expand description
A value that may be owned or not. Similar to std::borrow::Cow but does
not require Clone.
Variants§
Trait Implementations§
Source§impl<'a, TOwned, TBorrowed> Borrow<TBorrowed> for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, TOwned, TBorrowed> Borrow<TBorrowed> for MaybeOwned<'a, TOwned, TBorrowed>
Source§fn borrow(&self) -> &TBorrowed
fn borrow(&self) -> &TBorrowed
Immutably borrows from an owned value. Read more
Source§impl<'a, TOwned, TBorrowed> Clone for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, TOwned, TBorrowed> Clone for MaybeOwned<'a, TOwned, TBorrowed>
Source§impl<'a, TOwned: Debug, TBorrowed: Debug + ?Sized> Debug for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, TOwned: Debug, TBorrowed: Debug + ?Sized> Debug for MaybeOwned<'a, TOwned, TBorrowed>
Source§impl<'a, TOwned, TBorrowed> Deref for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, TOwned, TBorrowed> Deref for MaybeOwned<'a, TOwned, TBorrowed>
Source§impl<'a, 'k, TOwned, TBorrowed> Key<'k> for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, 'k, TOwned, TBorrowed> Key<'k> for MaybeOwned<'a, TOwned, TBorrowed>
Source§const CAN_OWN_BYTES: bool = TOwned::CAN_OWN_BYTES
const CAN_OWN_BYTES: bool = TOwned::CAN_OWN_BYTES
If true, this type can benefit from an owned
Vec<u8>. This flag is
used as a hint of whether to attempt to do memcpy operations in some
decoding operations to avoid extra allocations.Source§fn from_ord_bytes<'e>(bytes: ByteSource<'k, 'e>) -> Result<Self, Self::Error>
fn from_ord_bytes<'e>(bytes: ByteSource<'k, 'e>) -> Result<Self, Self::Error>
Deserialize a sequence of bytes previously encoded with
KeyEncoding::as_ord_bytes.Source§fn first_value() -> Result<Self, NextValueError>
fn first_value() -> Result<Self, NextValueError>
Return the first value in sequence for this type. Not all types
implement this.
Source§fn next_value(&self) -> Result<Self, NextValueError>
fn next_value(&self) -> Result<Self, NextValueError>
Return the next value in sequence for this type. Not all types implement
this. Instead of wrapping/overflowing, None should be returned.
Source§impl<'a, 'k, TOwned, TBorrowed> KeyEncoding for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, 'k, TOwned, TBorrowed> KeyEncoding for MaybeOwned<'a, TOwned, TBorrowed>
Source§const LENGTH: Option<usize> = TBorrowed::LENGTH
const LENGTH: Option<usize> = TBorrowed::LENGTH
The size of the key, if constant. If this type doesn’t produce the same
number of bytes for each value, this should be
None.Source§type Error = <TOwned as KeyEncoding>::Error
type Error = <TOwned as KeyEncoding>::Error
The error type that can be produced by either serialization or
deserialization.
Source§fn describe<Visitor>(visitor: &mut Visitor)where
Visitor: KeyVisitor,
fn describe<Visitor>(visitor: &mut Visitor)where
Visitor: KeyVisitor,
Describes this type by invoking functions on
visitor describing the
key being encoded. Read moreSource§impl<'a, TOwned, TBorrowed> PartialEq<TBorrowed> for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, TOwned, TBorrowed> PartialEq<TBorrowed> for MaybeOwned<'a, TOwned, TBorrowed>
Source§impl<'a, TOwned, TBorrowed> PartialEq for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, TOwned, TBorrowed> PartialEq for MaybeOwned<'a, TOwned, TBorrowed>
Source§impl<'a, TOwned, TBorrowed> PartialOrd<TBorrowed> for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, TOwned, TBorrowed> PartialOrd<TBorrowed> for MaybeOwned<'a, TOwned, TBorrowed>
Auto Trait Implementations§
impl<'a, TOwned, TBorrowed> Freeze for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, TOwned, TBorrowed> RefUnwindSafe for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, TOwned, TBorrowed> Send for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, TOwned, TBorrowed> Sync for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, TOwned, TBorrowed> Unpin for MaybeOwned<'a, TOwned, TBorrowed>
impl<'a, TOwned, TBorrowed> UnwindSafe for MaybeOwned<'a, TOwned, TBorrowed>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more