Skip to main content

attr_interface_impl

Attribute Macro attr_interface_impl 

Source
#[attr_interface_impl]
Expand description

Implement Attribute Interface for an Attribute. The interface trait must define a verify function with type AttrInterfaceVerifier.

Usage:

use pliron::derive::{attr_interface, attr_interface_impl, format_attribute};

#[def_attribute("dialect.name")]
#[format_attribute]
#[derive(PartialEq, Eq, Clone, Debug, Hash)]
struct MyAttr { }

    /// My first attribute interface.
#[attr_interface]
trait MyAttrInterface {
    fn monu(&self);
    fn verify(attr: &dyn Attribute, ctx: &Context) -> Result<()>
    where Self: Sized,
    {
         Ok(())
    }
}

#[attr_interface_impl]
impl MyAttrInterface for MyAttr
{
    fn monu(&self) { println!("monu"); }
}