1use std::{
5 collections::BTreeMap,
6 ops::{Deref, DerefMut},
7};
8
9use cfg_symbol::Symbol;
10
11#[derive(Ord, PartialOrd, Eq, PartialEq, Clone, Debug)]
14pub struct PerSymbolSetVal {
15 pub has_none: bool,
17 pub list: Vec<Symbol>,
19}
20
21pub type PerSymbolSets = BTreeMap<Symbol, PerSymbolSetVal>;
23
24pub trait PredictSets {
27 fn predict_sets(&self) -> &PerSymbolSets;
30}
31
32impl PerSymbolSetVal {
33 pub(crate) fn new() -> Self {
34 PerSymbolSetVal {
35 has_none: false,
36 list: vec![],
37 }
38 }
39
40 pub(crate) fn clear(&mut self) {
41 self.list.clear();
42 self.has_none = false;
43 }
44
45 pub fn has_none(&self) -> bool {
47 self.has_none
48 }
49
50 pub(crate) fn len(&self) -> usize {
51 self.list.len() + self.has_none as usize
52 }
53}
54
55impl Deref for PerSymbolSetVal {
56 type Target = Vec<Symbol>;
57 fn deref(&self) -> &Self::Target {
58 &self.list
59 }
60}
61
62impl DerefMut for PerSymbolSetVal {
63 fn deref_mut(&mut self) -> &mut Self::Target {
64 &mut self.list
65 }
66}