pub trait Update {
// Required method
fn update_from(&mut self, other: Self);
}Expand description
The Update trait is used for updating the state of a context from another.
Update allows incremental merging or synchronization between two instances of the same type.
§Examples
use node_flow::context::Update;
struct Stats {
count: usize,
}
impl Update for Stats {
fn update_from(&mut self, other: Self) {
self.count += other.count;
}
}
let mut a = Stats { count: 5 };
let b = Stats { count: 3 };
a.update_from(b);
assert_eq!(a.count, 8);Required Methods§
Sourcefn update_from(&mut self, other: Self)
fn update_from(&mut self, other: Self)
Merges or synchronizes the state of other into self.
The specifics depend on the implementor. For example it could be implemented as additive merging, overwriting fields, or some conflict resolution.
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 Update for LocalStorageImpl
Available on crate feature
local_storage_impl only.