use crate::NodeType;
use proc_macro2::TokenStream;
use std::collections::BTreeMap;
use std::fmt::{Display, Formatter};
pub type AnonUnions = BTreeMap<AnonUnionId, TokenStream>;
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct AnonUnionId {
pub(super) name: String,
}
impl AnonUnionId {
pub(crate) fn new(types: &[&NodeType]) -> Self {
Self {
name: NodeType::anon_union_type_name(types.iter().copied()),
}
}
pub(crate) fn query_capture(capture_variant_name: &str) -> Self {
Self {
name: capture_variant_name.to_string(),
}
}
}
impl Display for AnonUnionId {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.name)
}
}