Skip to main content

Keyed

Trait Keyed 

Source
pub trait Keyed {
    type Key: Eq + Hash + Clone + Send + 'static;

    // Required method
    fn key(&self) -> Self::Key;
}
Expand description

An item with a stable, owned identity — the merge key PersistedListModel dedupes and diffs by.

Key is owned (not borrowed, unlike the old MruEntry::Key: ?Sized shape) because it must be captured into a Patch (crate::flush::Patch) closure that crosses to the shared I/O worker thread — a borrow into T cannot outlive the mutation call that produced it.

Required Associated Types§

Source

type Key: Eq + Hash + Clone + Send + 'static

The key type. Typically String / PathBuf / a small Copy id.

Required Methods§

Source

fn key(&self) -> Self::Key

This item’s identity. Returned by value: cheap for the small key types this is meant for (clone a String/PathBuf/id), and it sidesteps borrow-lifetime issues entirely.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§