Trait UpdateValue

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§

type Value

The type of the value contained in the value.

Required Methods§

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§

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.

Implementors§

§

impl<T> UpdateValue for T
where T: WriteValue,

§

type Value = <T as WriteValue>::Value