xsd_parser/types/info/
union.rsuse std::ops::{Deref, DerefMut};
use crate::types::{Ident, TypeEq, Types};
use super::Base;
#[derive(Default, Debug, Clone)]
pub struct UnionInfo {
pub base: Base,
pub types: UnionTypesInfo,
}
#[derive(Debug, Clone)]
pub struct UnionTypeInfo {
pub type_: Ident,
}
#[derive(Default, Debug, Clone)]
pub struct UnionTypesInfo(Vec<UnionTypeInfo>);
impl TypeEq for UnionInfo {
fn type_eq(&self, other: &Self, ctx: &Types) -> bool {
let Self { base, types } = self;
base.type_eq(&other.base, ctx) && types.type_eq(&other.types, ctx)
}
}
impl UnionTypeInfo {
#[must_use]
pub fn new(type_: Ident) -> Self {
Self { type_ }
}
}
impl TypeEq for UnionTypeInfo {
fn type_eq(&self, other: &Self, types: &Types) -> bool {
let Self { type_ } = self;
type_.type_eq(&other.type_, types)
}
}
impl Deref for UnionTypesInfo {
type Target = Vec<UnionTypeInfo>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl DerefMut for UnionTypesInfo {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl TypeEq for UnionTypesInfo {
fn type_eq(&self, other: &Self, types: &Types) -> bool {
TypeEq::type_eq_iter(self.0.iter(), other.0.iter(), types)
}
}