reactive_graph::traits

Trait UpdateValue

Source
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§

Source

type Value

The type of the value contained in the value.

Required Methods§

Source

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§

Source

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§

Source§

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