use rand::{self, Rng};
use lazy_static::lazy_static;
use super::ValueData;
use crate::graph::cons::{GlobalCache, NodeCache};
pub type ValueCache<C = GlobalCache> = NodeCache<ValueData, C>;
lazy_static! {
pub static ref VALUE_CACHE: ValueCache = {
let mut rng = rand::thread_rng();
ValueCache::with_keys(rng.gen())
};
}
#[cfg(test)]
mod tests {
use crate::value::ValId;
#[test]
fn boolean_values_are_hash_consed() {
let vt = ValId::from(true);
let vf = ValId::from(false);
let vt2 = ValId::from(true);
let vf2 = ValId::from(false);
assert_eq!(vt, vt2);
assert_eq!(vf, vf2);
assert_ne!(vt, vf);
}
}