use super::*;
mod display;
mod iters;
#[derive(Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ConstraintDeclaration {
pub annotations: AnnotationNode,
pub generics: Vec<IdentifierNode>,
pub terms: Vec<ConstraintTerm>,
}
impl Debug for ConstraintDeclaration {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
let w = &mut f.debug_struct("Constraints");
if !self.annotations.is_empty() {
w.field("annotations", &self.annotations);
}
if !self.generics.is_empty() {
w.field("generics", &self.generics);
}
if !self.terms.is_empty() {
w.field("terms", &self.terms);
}
w.finish()
}
}
#[derive(Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum ConstraintTerm {
Macro(ProceduralNode),
Field(FieldDeclaration),
Method(MethodDeclaration),
Domain(DomainDeclaration),
}
impl Default for ConstraintDeclaration {
fn default() -> Self {
Self { annotations: Default::default(), generics: vec![], terms: vec![] }
}
}
impl ConstraintDeclaration {
pub fn is_empty(&self) -> bool {
self.generics.is_empty() && self.terms.is_empty() && self.annotations.is_empty()
}
}