pub struct Mapping<T>(/* private fields */);Expand description
A mapping between values and IDs.
This structure allows for bidirectional lookup between values and their assigned numeric IDs, with interior mutability for shared access.
Implementations§
Source§impl<T: Ord + Clone> Mapping<T>
impl<T: Ord + Clone> Mapping<T>
Sourcepub fn register(&self, value: T) -> Id
pub fn register(&self, value: T) -> Id
Registers a new value in the mapping and returns its assigned ID.
Sourcepub fn to_id(&self, value: T) -> Id
pub fn to_id(&self, value: T) -> Id
Gets the ID for a value, registering it if not already present.
Sourcepub fn binding(&self, source: &Binding<T>) -> Binding<Id>where
T: 'static,
pub fn binding(&self, source: &Binding<T>) -> Binding<Id>where
T: 'static,
Creates a binding that maps between a value binding and an ID binding.
This is useful for reactive UI systems where you need to work with IDs rather than the actual values but still maintain synchronization.
§Panics
Panics if the provided Id does not correspond to any value in the mapping.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Mapping<T>
impl<T> !RefUnwindSafe for Mapping<T>
impl<T> !Send for Mapping<T>
impl<T> !Sync for Mapping<T>
impl<T> Unpin for Mapping<T>
impl<T> !UnwindSafe for Mapping<T>
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