pub struct Id<T> { /* private fields */ }Expand description
Used as a key to access an instance inside a IdVec
Implementations§
Source§impl<T> Id<T>
impl<T> Id<T>
pub fn from_index(index: Index) -> Self
Sourcepub fn of<'s>(self, vec: &'s IdVec<T>) -> &'s T
pub fn of<'s>(self, vec: &'s IdVec<T>) -> &'s T
Convenience function which allows writing the index first, and the IdVec afterwards.
Example: the_selected_entity.of(entities)
Panics when calling on an invalid id
Sourcepub fn of_mut<'s>(self, vec: &'s mut IdVec<T>) -> &'s mut T
pub fn of_mut<'s>(self, vec: &'s mut IdVec<T>) -> &'s mut T
Convenience function which allows writing the index first, and the IdVec afterwards.
Example: the_selected_entity.of_mut(entities)
Panics when calling on an invalid id
Sourcepub fn try_of<'s>(self, vec: &'s IdVec<T>) -> Option<&'s T>
pub fn try_of<'s>(self, vec: &'s IdVec<T>) -> Option<&'s T>
Convenience function which allows writing the index first, and the IdVec afterwards.
Example: the_selected_entity.try_of(entities)
Sourcepub fn try_of_mut<'s>(self, vec: &'s mut IdVec<T>) -> Option<&'s mut T>
pub fn try_of_mut<'s>(self, vec: &'s mut IdVec<T>) -> Option<&'s mut T>
Convenience function which allows writing the index first, and the IdVec afterwards.
Example: the_selected_entity.try_of_mut(entities)
Sourcepub fn index_value(self) -> Index
pub fn index_value(self) -> Index
The actual integer value for this Id.