Skip to main content

pumpkin_core/propagation/
propagator_id.rs

1use crate::containers::StorageKey;
2
3/// An identifier to a propagator instance within the solver.
4/// Each propagator is assigned a unique identifier at runtime.
5#[repr(transparent)]
6#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
7pub struct PropagatorId(pub(crate) u32);
8
9impl std::fmt::Display for PropagatorId {
10    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11        write!(f, "PropagatorId({})", self.0)
12    }
13}
14
15impl StorageKey for PropagatorId {
16    fn index(&self) -> usize {
17        self.0 as usize
18    }
19
20    fn create_from_index(index: usize) -> Self {
21        PropagatorId(index as u32)
22    }
23}