multiversx_chain_vm::with_shared

Function with_shared_mut_ref

Source
pub fn with_shared_mut_ref<T, F, R>(t: &mut T, f: F) -> R
where T: Clone, F: FnOnce(Rc<T>) -> R,
Expand description

Temporarily converts a mutable reference into a reference-counted smart pointer (Rc).

This only takes as long as the closure f is executed.

All subsequent Rc clones must be dropped before f terminates, otherwise the function will panic.

The Clone of the argument is not used, except to preserve memory consistency in case of failure.

See the Shared type for a safer implementation, which does not require Clone.