Skip to main content

pumpkin_core/engine/cp/trailed/
trailed_integer.rs

1use crate::containers::StorageKey;
2
3/// An integer whose value is automatically restored upon backtracking to its previous value at the
4/// checkpoint to which backtracking occurred.
5#[derive(Debug, Clone, Copy)]
6pub struct TrailedInteger {
7    id: u32,
8}
9
10impl StorageKey for TrailedInteger {
11    fn index(&self) -> usize {
12        self.id as usize
13    }
14
15    fn create_from_index(index: usize) -> Self {
16        Self { id: index as u32 }
17    }
18}