use crate::atom::head::AtomBounds;
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum State {
Existing(AtomBounds),
Replace(AtomBounds),
Remove(AtomBounds),
Insert,
}
impl Default for State {
fn default() -> Self {
Self::Insert
}
}
impl State {
pub fn has_existed(&self) -> bool {
matches!(self, Self::Existing(_) | Self::Replace(_) | Self::Remove(_))
}
pub fn is_existing(&self) -> bool {
matches!(self, Self::Existing(_))
}
pub fn replace_existing(&mut self) {
if let Self::Existing(b) = self {
*self = Self::Replace(b.clone())
}
}
pub fn remove_existing(&mut self) {
if let Self::Existing(b) = self {
*self = Self::Remove(b.clone())
}
}
}