Skip to main content

Key

Trait Key 

Source
pub trait Key: Any + Debug {
    // Required methods
    fn key_id(&self) -> KeyId;
    fn eq_key(&self, other: &dyn Key) -> bool;
    fn clone_box(&self) -> Box<dyn Key>;
    fn as_any(&self) -> &dyn Any;
}
Expand description

A type-erased identity used by widgets and reconciliation algorithms. Implementors should be immutable value types.

Required Methods§

Source

fn key_id(&self) -> KeyId

Returns a stable, process-local identity for this key value.

Source

fn eq_key(&self, other: &dyn Key) -> bool

Supports equality after type erasure without requiring dyn Key to implement Eq itself.

Source

fn clone_box(&self) -> Box<dyn Key>

Clones a concrete key through a trait object.

Source

fn as_any(&self) -> &dyn Any

Provides a downcast hook for custom key implementations.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Key for KeyHandle

Source§

impl Key for UniqueKey

Source§

impl<T> Key for ValueKey<T>
where T: Any + Clone + Eq + Hash + Debug,