pub trait MutableHelper {
type Value;
// Required methods
fn with_mut<R>(&self, callback: impl FnOnce(&mut Self::Value) -> R) -> R;
fn with_ref<R>(&self, callback: impl FnOnce(&Self::Value) -> R) -> R;
}Expand description
The single entry point to a Mutable, for both the single-threaded and the multi-threaded
backend.
The callback is handed a plain reference rather than the backend’s guard, which is what makes
the lock impossible to hold longer than the callback: the guard is a temporary inside
with_mut / with_ref and is released before either returns. Everything the callback produces
therefore lives — and is dropped — outside the lock.
See the module documentation for the rules a callback has to follow.
Required Associated Types§
Required Methods§
fn with_mut<R>(&self, callback: impl FnOnce(&mut Self::Value) -> R) -> R
fn with_ref<R>(&self, callback: impl FnOnce(&Self::Value) -> R) -> R
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".