use crate::{
context::Context,
identifier::{Identifier, underscore},
result::Result,
};
pub trait Verify {
fn verify(&self, ctx: &Context) -> Result<()>;
}
#[deprecated(
since = "0.14.0",
note = "Consider using `pliron::derive::verify_succ` instead"
)]
#[macro_export]
macro_rules! impl_verify_succ {
($op_name:path) => {
impl $crate::common_traits::Verify for $op_name {
fn verify(&self, _ctx: &$crate::context::Context) -> $crate::result::Result<()> {
Ok(())
}
}
};
}
pub trait Named {
fn given_name(&self, ctx: &Context) -> Option<Identifier>;
fn id(&self, ctx: &Context) -> Identifier;
fn unique_name(&self, ctx: &Context) -> Identifier {
match self.given_name(ctx) {
Some(given_name) => given_name + underscore() + self.id(ctx),
None => self.id(ctx),
}
}
}
pub trait RcShare {
fn share(&self) -> Self;
}