pub enum MaybeOwnedValue<'a> {
Borrowed(BorrowedValue<'a>),
Owned(OwnedValue),
}Expand description
A value that may be either borrowed or owned.
This enum provides flexibility when the ownership semantics depend on runtime conditions.
§Performance
The borrowed variant has zero allocation overhead. The owned variant allocates once on creation.
Variants§
Implementations§
Source§impl<'a> MaybeOwnedValue<'a>
impl<'a> MaybeOwnedValue<'a>
Sourcepub fn into_owned(self) -> OwnedValue
pub fn into_owned(self) -> OwnedValue
Converts to an owned value, cloning if necessary.
Sourcepub fn is_borrowed(&self) -> bool
pub fn is_borrowed(&self) -> bool
Returns true if this is a borrowed value.
Trait Implementations§
Source§impl<'a> AsRef<[u8]> for MaybeOwnedValue<'a>
impl<'a> AsRef<[u8]> for MaybeOwnedValue<'a>
Source§impl<'a> Clone for MaybeOwnedValue<'a>
impl<'a> Clone for MaybeOwnedValue<'a>
Source§fn clone(&self) -> MaybeOwnedValue<'a>
fn clone(&self) -> MaybeOwnedValue<'a>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a> Debug for MaybeOwnedValue<'a>
impl<'a> Debug for MaybeOwnedValue<'a>
Source§impl<'a> From<BorrowedValue<'a>> for MaybeOwnedValue<'a>
impl<'a> From<BorrowedValue<'a>> for MaybeOwnedValue<'a>
Source§fn from(value: BorrowedValue<'a>) -> Self
fn from(value: BorrowedValue<'a>) -> Self
Converts to this type from the input type.
Source§impl<'a> From<OwnedValue> for MaybeOwnedValue<'a>
impl<'a> From<OwnedValue> for MaybeOwnedValue<'a>
Source§fn from(value: OwnedValue) -> Self
fn from(value: OwnedValue) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl<'a> Freeze for MaybeOwnedValue<'a>
impl<'a> RefUnwindSafe for MaybeOwnedValue<'a>
impl<'a> Send for MaybeOwnedValue<'a>
impl<'a> Sync for MaybeOwnedValue<'a>
impl<'a> Unpin for MaybeOwnedValue<'a>
impl<'a> UnwindSafe for MaybeOwnedValue<'a>
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