Struct Circuit

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn outputs(&self) -> &[Gate]

Returns the output gates.

Source

pub fn output_names(&self) -> &[String]

Returns the names of the output gates, where unnamed output gates use the empty String.

Source

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.

Source

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.

Source

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§

Source§

impl Default for Circuit

Source§

fn default() -> Circuit

Returns the “default value” for a type. Read more
Source§

impl From<Gate> for Circuit

Source§

fn from(gate: Gate) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.