use std::collections::BTreeSet;
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct PropertyRequirement {
pub alias: String,
pub tag_name: Option<String>,
pub prop_names: BTreeSet<String>,
pub full_value: bool,
}
impl PropertyRequirement {
pub fn new(alias: impl Into<String>) -> Self {
Self {
alias: alias.into(),
..Default::default()
}
}
pub fn merge(&mut self, other: &PropertyRequirement) {
self.tag_name = other.tag_name.clone().or_else(|| self.tag_name.clone());
self.prop_names.extend(other.prop_names.iter().cloned());
self.full_value |= other.full_value;
}
pub fn is_narrowable(&self) -> bool {
!self.full_value && !self.prop_names.is_empty()
}
}