pub enum Shareable<T> {
Owned(T),
Shared(Arc<T>),
}
๐Deprecated since 0.57.0: replaced by BlockchainVMRef and Arc
Expand description
Wraps an object and provides mutable access to it.
The point is that sometimes we want to stop mutability and proliferate reference-counted pointers to it.
This happens in a controlled environment, in the with_shared
method closure argument.
All reference-counted pointers are expected to be dropped until that closure finishes.
Variantsยง
Owned(T)
๐Deprecated since 0.57.0: replaced by BlockchainVMRef and Arc
๐Deprecated since 0.57.0: replaced by BlockchainVMRef and Arc
Implementationsยง
pub fn new(t: T) -> Self
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Destroys the object and returns the contents.
The main functionality of Shared
.
Temporarily makes the object immutable, and creates a Rc pointer to the contents, which can then be cloned.
Important restriction: all Rc pointers creates from the one given to the closure f
must be dropped before its execution ends.
Otherwise the operation will panic.
Trait Implementationsยง
Auto Trait Implementationsยง
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> 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