hugr_llvm/utils/
logic_op_builder.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use hugr::{
    builder::{BuildError, Dataflow},
    std_extensions::logic::LogicOp,
    Wire,
};

pub trait LogicOpBuilder: Dataflow {
    fn add_and(&mut self, x1: Wire, x2: Wire) -> Result<Wire, BuildError> {
        Ok(self.add_dataflow_op(LogicOp::And, [x1, x2])?.out_wire(0))
    }

    fn add_not(&mut self, x1: Wire) -> Result<Wire, BuildError> {
        Ok(self.add_dataflow_op(LogicOp::Not, [x1])?.out_wire(0))
    }
}

impl<D: Dataflow> LogicOpBuilder for D {}