81 lines
1.6 KiB
Rust
81 lines
1.6 KiB
Rust
pub struct PolymorphicEnumInnerBuild {
|
|
name: String,
|
|
members: Vec<PolymorphicEnumInnerBuildMember>,
|
|
rules: Vec<PolymorphicEnumInnerBuildRule>,
|
|
}
|
|
|
|
impl PolymorphicEnumInnerBuild {
|
|
pub fn new(
|
|
name: &str,
|
|
members: Vec<PolymorphicEnumInnerBuildMember>,
|
|
rules: Vec<PolymorphicEnumInnerBuildRule>,
|
|
) -> Self {
|
|
Self {
|
|
name: name.to_string(),
|
|
members,
|
|
rules,
|
|
}
|
|
}
|
|
|
|
pub fn name(&self) -> &str {
|
|
&self.name
|
|
}
|
|
|
|
pub fn members(&self) -> impl Iterator<Item = &PolymorphicEnumInnerBuildMember> {
|
|
self.members.iter()
|
|
}
|
|
|
|
pub fn rules(&self) -> impl Iterator<Item = &PolymorphicEnumInnerBuildRule> {
|
|
self.rules.iter()
|
|
}
|
|
}
|
|
|
|
pub struct PolymorphicEnumInnerBuildMember {
|
|
name: String,
|
|
kind: PolymorphicEnumInnerBuildMemberKind,
|
|
}
|
|
|
|
impl PolymorphicEnumInnerBuildMember {
|
|
pub fn new(name: &str, kind: PolymorphicEnumInnerBuildMemberKind) -> Self {
|
|
Self {
|
|
name: name.to_string(),
|
|
kind,
|
|
}
|
|
}
|
|
|
|
pub fn name(&self) -> &str {
|
|
&self.name
|
|
}
|
|
|
|
pub fn kind(&self) -> &PolymorphicEnumInnerBuildMemberKind {
|
|
&self.kind
|
|
}
|
|
}
|
|
|
|
pub enum PolymorphicEnumInnerBuildMemberKind {
|
|
Leaf,
|
|
Struct,
|
|
}
|
|
|
|
pub struct PolymorphicEnumInnerBuildRule {
|
|
name: String,
|
|
with: String,
|
|
}
|
|
|
|
impl PolymorphicEnumInnerBuildRule {
|
|
pub fn new(name: &str, with: &str) -> Self {
|
|
Self {
|
|
name: name.to_string(),
|
|
with: with.to_string(),
|
|
}
|
|
}
|
|
|
|
pub fn name(&self) -> &str {
|
|
&self.name
|
|
}
|
|
|
|
pub fn with(&self) -> &str {
|
|
&self.with
|
|
}
|
|
}
|