pub struct Circuit { /* private fields */ }Expand description
A boolean circuit with named inputs and outputs.
Input variables are identified by their name.
The gates in the circuit are Gates.
Implementations§
Source§impl Circuit
impl Circuit
Sourcepub fn from_unnamed_outputs(outputs: impl IntoIterator<Item = Gate>) -> Self
pub fn from_unnamed_outputs(outputs: impl IntoIterator<Item = Gate>) -> Self
Creates a circuit from unnamed outputs. Note that the Gates can
share predecessors. Any two input gates in the circuit with the same
name are considered identical.
Sourcepub fn with_input_order(
self,
input_names: impl IntoIterator<Item = impl ToString>,
) -> Result<Self, String>
pub fn with_input_order( self, input_names: impl IntoIterator<Item = impl ToString>, ) -> Result<Self, String>
Adds the order of input gates to the circuit, or changes it.
Sourcepub fn from_named_outputs(
items: impl IntoIterator<Item = (Gate, impl ToString)>,
) -> Self
pub fn from_named_outputs( items: impl IntoIterator<Item = (Gate, impl ToString)>, ) -> Self
Creates a circuit from (uniquely) named outputs. Note that the Gates can
share predecessors. Any two input gates in the circuit with the same
name are considered identical.
The empty string can be used to not name outputs.
Panics if the output names are not unique.
Sourcepub fn input_names(&self) -> impl Iterator<Item = &str> + '_
pub fn input_names(&self) -> impl Iterator<Item = &str> + '_
Returns the names of the input gates either in the order given by [with_input_order] or
otherwise from a circuit traversal.
Sourcepub fn output_names(&self) -> &[String]
pub fn output_names(&self) -> &[String]
Returns the names of the output gates, where unnamed output gates use the empty String.
Sourcepub fn named_outputs(&self) -> impl Iterator<Item = (&Gate, &String)>
pub fn named_outputs(&self) -> impl Iterator<Item = (&Gate, &String)>
Returns an iterator over the output gates and their names, where unnamed output gates use the empty string.
Sourcepub fn iter(&self) -> impl Iterator<Item = &Gate>
pub fn iter(&self) -> impl Iterator<Item = &Gate>
Creates an iterator over the graph (the output gates and all their predecessors) that returns each gate exactly once.
Sourcepub fn post_visit_iter(&self) -> impl Iterator<Item = &Gate>
pub fn post_visit_iter(&self) -> impl Iterator<Item = &Gate>
Creates an iterator over the graph (the output gates and all their predecessors) with post-visit order, visiting each gate exactly once. This means that the predecessors of each gate are always visited before the gate itself.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Circuit
impl RefUnwindSafe for Circuit
impl !Send for Circuit
impl !Sync for Circuit
impl Unpin for Circuit
impl UnwindSafe for Circuit
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more