pub enum Borrowned<'b, T> {
Owned(T),
Borrowed(&'b mut T),
}
Expand description
A smart pointer that either owns or mutably borrows.
Variants
Owned(T)
Contains the owned value
Borrowed(&'b mut T)
Contains the borrowed value
Implementations
Returns true
if the contained value is owned.
Examples
let x: Borrowned<u32> = Borrowned::Owned(2);
assert_eq!(x.is_owned(), true);
let mut y = 2;
let x: Borrowned<u32> = Borrowned::Borrowed(&mut y);
assert_eq!(x.is_owned(), false);
Returns true
if the contained value is borrowed.
Examples
let x: Borrowned<u32> = Borrowned::Owned(2);
assert_eq!(x.is_borrowed(), false);
let mut y = 2;
let x: Borrowned<u32> = Borrowned::Borrowed(&mut y);
assert_eq!(x.is_borrowed(), true);
Trait Implementations
Mutably borrows from an owned value. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl<'b, T> RefUnwindSafe for Borrowned<'b, T> where
T: RefUnwindSafe,
impl<'b, T> !UnwindSafe for Borrowned<'b, T>
Blanket Implementations
Mutably borrows from an owned value. Read more