essential_constraint_vm/
cached.rs1use std::{collections::HashSet, sync::OnceLock};
2
3use essential_types::{solution::SolutionData, Hash};
4
5use crate::access::init_predicate_exists;
6
7#[derive(Default, Debug, PartialEq)]
8pub struct LazyCache {
10 pub dec_var_hashes: OnceLock<HashSet<Hash>>,
13}
14
15impl LazyCache {
16 pub fn new() -> Self {
18 Self::default()
19 }
20
21 pub fn get_dec_var_hashes(&self, data: &[SolutionData]) -> &HashSet<Hash> {
25 self.dec_var_hashes
26 .get_or_init(|| init_predicate_exists(data).collect())
27 }
28}