From dad511c8e5beb96b7af7e36ea02265c435639ec6 Mon Sep 17 00:00:00 2001 From: Agustin Borgna Date: Thu, 21 Sep 2023 11:52:14 +0100 Subject: [PATCH] Query whether a port is linear in command --- src/circuit/command.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/circuit/command.rs b/src/circuit/command.rs index d88d62fb..60d27001 100644 --- a/src/circuit/command.rs +++ b/src/circuit/command.rs @@ -146,6 +146,14 @@ impl<'circ, Circ: Circuit> Command<'circ, Circ> { .find(|(cu, _, _)| *cu == unit) .map(|(_, port, _)| port) } + + /// Returns whether the port is a linear port. + #[inline] + pub fn is_linear_port(&self, port: Port) -> bool { + self.optype() + .port_kind(port) + .map_or(false, |kind| kind.is_linear()) + } } impl<'a, 'circ, Circ: Circuit> UnitLabeller for &'a Command<'circ, Circ> {