pub trait UpdateValue: DefinedAt {
type Value;
// Required method
fn try_update_value<U>(
&self,
fun: impl FnOnce(&mut Self::Value) -> U,
) -> Option<U>;
// Provided method
fn update_value(&self, fun: impl FnOnce(&mut Self::Value)) { ... }
}
Expand description
A variation of the Update
trait that provides a signposted “always-non-reactive” API.
E.g. for StoredValue
.
Required Associated Types§
Required Methods§
Sourcefn try_update_value<U>(
&self,
fun: impl FnOnce(&mut Self::Value) -> U,
) -> Option<U>
fn try_update_value<U>( &self, fun: impl FnOnce(&mut Self::Value) -> U, ) -> Option<U>
Updates the value, returning the value that is
returned by the update function, or None
if the value has already been disposed.
Provided Methods§
Sourcefn update_value(&self, fun: impl FnOnce(&mut Self::Value))
fn update_value(&self, fun: impl FnOnce(&mut Self::Value))
Updates the value.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.