pub struct ModeId(/* private fields */);Expand description
Canonical identity of a mode. Interned-string for Copy + Eq + Hash at zero allocation cost on the hot path.
Two ModeIds are equal iff their names are equal; equality is
pointer-cheap because internment::Intern<String> deduplicates
at construction. Across crates, the identity is the string,
not a Rust type – this is intentional, since lifecycle events
and registry lookups are uniform across built-in and plugin
modes (mode-architecture.md §1, “modes are an interface, not
a distribution unit”).
Naming convention: mode names always end in -mode. Group
names (M.2) never end in -mode. The disambiguation rule
in mode-architecture.md §6.7.1 depends on this convention.
Ord compares the names (alphabetical), not intern addresses, so
orderings built from it are stable across runs.
§Examples
use lattice_keymap::ModeId;
let a = ModeId::new("diff-mode");
assert_eq!(a, ModeId::new("diff-mode"));
assert_eq!(a.as_str(), "diff-mode");
assert!(a < ModeId::new("magit-mode"));Implementations§
Trait Implementations§
impl Copy for ModeId
impl Eq for ModeId
Source§impl Ord for ModeId
impl Ord for ModeId
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for ModeId
impl PartialOrd for ModeId
impl StructuralPartialEq for ModeId
Auto Trait Implementations§
impl Freeze for ModeId
impl RefUnwindSafe for ModeId
impl Send for ModeId
impl Sync for ModeId
impl Unpin for ModeId
impl UnsafeUnpin for ModeId
impl UnwindSafe for ModeId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.