Skip to main content

type_interface_impl

Attribute Macro type_interface_impl 

Source
#[type_interface_impl]
Expand description

Implement Type Interface for a Type. The interface trait must define a verify function with type TypeInterfaceVerifier.

Usage:

use pliron::derive::{type_interface, type_interface_impl, format_type};

#[def_type("dialect.name")]
#[format_type]
#[derive(PartialEq, Eq, Clone, Debug, Hash)]
struct MyType { }

#[type_interface]
/// My first type interface.
trait MyTypeInterface {
    fn monu(&self);
    fn verify(r#type: &dyn Type, ctx: &Context) -> Result<()>
    where Self: Sized,
    {
         Ok(())
    }
}

#[type_interface_impl]
impl MyTypeInterface for MyType
{
    fn monu(&self) { println!("monu"); }
}