pub trait DiffKey {
type Key<'a>: PartialEq
where Self: 'a;
// Required method
fn key(&self) -> Self::Key<'_>;
}Expand description
A trait that must be implemented by any type T that is part of a
Vec<T> being diffed.
The value for Key should be unique to that element in the list (akin to React in JS land). It allows the diff algorithm to detect whether elements have been changed, moved or completely replaced.
If there is no sensible value to use as the key, consider making a dummy ID
to attach to T. Otherwise, it is acceptable to use a null value like (), but
this may cause the diff algorithm to run slowly and generate unnecessarily large diffs
Required Associated Types§
Required Methods§
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.