pumpkin_core/propagation/
local_id.rs1use crate::containers::StorageKey;
2
3#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
6pub struct LocalId(u32);
7
8impl LocalId {
9 pub const fn from(value: u32) -> Self {
10 LocalId(value)
11 }
12
13 pub const fn successor(self) -> Self {
15 LocalId(self.0 + 1)
16 }
17
18 pub fn unpack(self) -> u32 {
19 self.0
20 }
21}
22
23impl StorageKey for LocalId {
24 fn index(&self) -> usize {
25 self.0 as usize
26 }
27
28 fn create_from_index(index: usize) -> Self {
29 LocalId::from(index as u32)
30 }
31}
32
33impl std::fmt::Display for LocalId {
34 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
35 write!(f, "{}", self.0)
36 }
37}