pub struct CommandId(/* private fields */);Expand description
Opaque command identifier. Wrap an enum variant (or a u32) to make it
comparable and hashable without storing strings at runtime.
§Example
use egui_command::CommandId;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
enum AppCmd {
ShowHelp,
RenameProfile,
}
let id = CommandId::new(AppCmd::ShowHelp);
assert_eq!(id, CommandId::new(AppCmd::ShowHelp));
assert_ne!(id, CommandId::new(AppCmd::RenameProfile));Implementations§
Source§impl CommandId
impl CommandId
Sourcepub fn new<T: Hash>(value: T) -> Self
pub fn new<T: Hash>(value: T) -> Self
Create a CommandId from any value that can be hashed.
Uses FxHasher — a deterministic, platform-stable hasher — so that the
same value always produces the same CommandId across process restarts,
Rust versions, and platforms.
Sourcepub fn raw(self) -> u64
pub fn raw(self) -> u64
Raw numeric value.
The underlying hash is stable within a build (same input → same output
across runs, versions, and platforms when using the same FxHasher).
Suitable for in-memory keying; treat persistence across binary upgrades
with caution unless the hashed type’s discriminant is stable.
Trait Implementations§
impl Copy for CommandId
impl Eq for CommandId
impl StructuralPartialEq for CommandId
Auto Trait Implementations§
impl Freeze for CommandId
impl RefUnwindSafe for CommandId
impl Send for CommandId
impl Sync for CommandId
impl Unpin for CommandId
impl UnsafeUnpin for CommandId
impl UnwindSafe for CommandId
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
Mutably borrows from an owned value. Read more