use crate::ArenaIndex;
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct GuardedEntity<GuardIdx, EntityIdx> {
guard_idx: GuardIdx,
entity_idx: EntityIdx,
}
impl<GuardIdx, EntityIdx> GuardedEntity<GuardIdx, EntityIdx> {
pub fn new(guard_idx: GuardIdx, entity_idx: EntityIdx) -> Self {
Self {
guard_idx,
entity_idx,
}
}
}
impl<GuardIdx, EntityIdx> GuardedEntity<GuardIdx, EntityIdx>
where
GuardIdx: ArenaIndex,
EntityIdx: ArenaIndex,
{
pub fn entity_index(&self, guard_index: GuardIdx) -> Option<EntityIdx> {
if self.guard_idx.into_usize() != guard_index.into_usize() {
return None;
}
Some(self.entity_idx)
}
}