use crate::parser::logic::{FlowLogRule, LoopBlock};
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) enum Segment {
Plain(Vec<FlowLogRule>),
Loop(LoopBlock),
Fixpoint(LoopBlock),
}
impl Segment {
#[must_use]
pub(crate) fn as_rules(&self) -> &[FlowLogRule] {
match self {
Self::Plain(rules) => rules,
Self::Loop(_) | Self::Fixpoint(_) => &[],
}
}
#[must_use]
pub(crate) fn as_loop(&self) -> Option<&LoopBlock> {
match self {
Self::Loop(block) | Self::Fixpoint(block) => Some(block),
Self::Plain(_) => None,
}
}
pub(crate) fn as_rules_mut(&mut self) -> &mut [FlowLogRule] {
match self {
Self::Plain(rules) => rules,
Self::Loop(_) | Self::Fixpoint(_) => &mut [],
}
}
pub(crate) fn as_loop_mut(&mut self) -> Option<&mut LoopBlock> {
match self {
Self::Loop(block) | Self::Fixpoint(block) => Some(block),
Self::Plain(_) => None,
}
}
}