inst_derive 0.1.2

Derive macro for tagged union enums implementing the Instantiable trait in safety-net
Documentation

crates.io

Description

Derive macro for the Instantiable trait in safety-net.

Makes it easier to group Instantiable structs into a single enum.

Example

Use the #[instantiable(constant)] attribute on a variant to specify which variant should be used for from_constant(). The variant must have a pub fn from_constant(val: Logic) -> Option<Self> method that returns an Option of the variant type.

use inst_derive::Instantiable;
use safety_net::{Gate, Identifier, Instantiable, Logic, Net, Parameter};
#[derive(Debug, Clone, Instantiable)]
enum Cell {
    #[instantiable(constant)]
    Gate(Gate),
    // additional variants
}