Skip to main content

op_interface

Attribute Macro op_interface 

Source
#[op_interface]
Expand description

Declare an Op interface, which can be implemented by any Op.

If the interface requires any other interface to be already implemented, they can be specified super-traits.

When an Op is verified, its interfaces are also automatically verified, with guarantee that a super-interface is verified before an interface itself is.

Example: Here SameOperandsAndResultType and SymbolOpInterface are super interfaces for the new interface MyOpIntr.

  /// MyOpIntr is my first op interface.
  #[op_interface]
  trait MyOpIntr: SameOperandsAndResultType + SymbolOpInterface {
      fn verify(_op: &dyn Op, _ctx: &Context) -> Result<()>
      where Self: Sized,
      {
          Ok(())
      }
  }