pub struct Cow<'a, T> { /* private fields */ }
Expand description
A pointer-sized object that holds either a borrow (&'a T
) or a boxed value (Box<T>
).
TODO doc: implements deref, construction, ToOwned, etc.
§Notes
Because it uses PointerValuePair
internally, T
cannot not be a zero-sized type.
Implementations§
Source§impl<'a, T> Cow<'a, T>where
T: Clone,
impl<'a, T> Cow<'a, T>where
T: Clone,
Sourcepub fn into_owned(self) -> Box<T>
pub fn into_owned(self) -> Box<T>
Converts this Cow
into a Box<T>
. If this Cow
is a borrow, clones the value and boxes it.
Sourcepub fn into_owned_cow<'b>(self) -> Cow<'b, T>
pub fn into_owned_cow<'b>(self) -> Cow<'b, T>
Converts this Cow
into an owned Cow
by cloning the value and boxing it, if it is borrowed.
Trait Implementations§
Auto Trait Implementations§
impl<'a, T> Freeze for Cow<'a, T>
impl<'a, T> RefUnwindSafe for Cow<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for Cow<'a, T>
impl<'a, T> Sync for Cow<'a, T>where
T: Sync,
impl<'a, T> Unpin for Cow<'a, T>where
T: Unpin,
impl<'a, T> UnwindSafe for Cow<'a, T>where
T: UnwindSafe + RefUnwindSafe,
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