Struct Gate

Source
pub struct Gate(/* private fields */);
Expand description

A gate in a boolean circuit.

The inputs of the circuit are variables identified by their name. Other types of gates are constant gates or operations that have predecessors.

The clone operation only performs a shallow clone and thus allows sharing of gates.

Implementations§

Source§

impl Gate

Source

pub fn id(&self) -> usize

Returns an identifier for the gate which is unique in the circuit but not stable across program reloads.

Source

pub fn operation(&self) -> &Operation

Returns the operation of the gate.

Source

pub fn iter(&self) -> impl Iterator<Item = &Gate>

Creates an iterator over the graph (the gate itself and all its 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 gate itself and all its 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.

Source

pub fn to_string_as_tree(&self) -> String

Turns the gate and its predecessors into a string representation, repeating shared gates.

Source

pub fn try_to_constant(&self) -> Option<bool>

Returns the value of the gate if it is a constant input gate.

Source

pub fn gate_count(&self) -> (usize, usize)

Returns the number of variables and inner gates (gates not counting variables or constants) in the circuit.

This depends on how the circuit was constructed, i.e. it does not deduplicate sub-circuits, but it does deduplicate variables with the same name.

Trait Implementations§

Source§

impl BitAnd for &Gate

Source§

type Output = Gate

The resulting type after applying the & operator.
Source§

fn bitand(self, other: &Gate) -> Gate

Performs the & operation. Read more
Source§

impl BitAnd for Gate

Source§

type Output = Gate

The resulting type after applying the & operator.
Source§

fn bitand(self, other: Gate) -> Gate

Performs the & operation. Read more
Source§

impl BitOr for &Gate

Source§

type Output = Gate

The resulting type after applying the | operator.
Source§

fn bitor(self, other: &Gate) -> Gate

Performs the | operation. Read more
Source§

impl BitOr for Gate

Source§

type Output = Gate

The resulting type after applying the | operator.
Source§

fn bitor(self, other: Gate) -> Gate

Performs the | operation. Read more
Source§

impl BitXor for &Gate

Source§

type Output = Gate

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, other: &Gate) -> Gate

Performs the ^ operation. Read more
Source§

impl BitXor for Gate

Source§

type Output = Gate

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, other: Gate) -> Gate

Performs the ^ operation. Read more
Source§

impl Clone for Gate

Source§

fn clone(&self) -> Gate

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Gate

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&Literal> for Gate

Source§

fn from(literal: &Literal) -> Gate

Converts a literal to either a variable or a gate that is the negation of a variable.

Source§

impl From<&str> for Gate

Source§

fn from(name: &str) -> Gate

Constructs a new gate representing an input variable.

Two variables with the same name are considered equal, even if they are different {Gate} instances.

Source§

impl From<Gate> for Circuit

Source§

fn from(gate: Gate) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Gate

Source§

fn from(name: String) -> Gate

Constructs a new gate representing an input variable.

Two variables with the same name are considered equal, even if they are different gate instances.

Source§

impl From<bool> for Gate

Source§

fn from(value: bool) -> Gate

Creates a constant gate.

Source§

impl<'a> IntoIterator for &'a Gate

Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator over the graph that returns each gate exactly once.

Source§

type Item = &'a Gate

The type of the elements being iterated over.
Source§

type IntoIter = GraphIterator<'a>

Which kind of iterator are we turning this into?
Source§

impl Not for &Gate

Source§

type Output = Gate

The resulting type after applying the ! operator.
Source§

fn not(self) -> Gate

Performs the unary ! operation. Read more
Source§

impl Not for Gate

Source§

type Output = Gate

The resulting type after applying the ! operator.
Source§

fn not(self) -> Gate

Performs the unary ! operation. Read more

Auto Trait Implementations§

§

impl Freeze for Gate

§

impl RefUnwindSafe for Gate

§

impl !Send for Gate

§

impl !Sync for Gate

§

impl Unpin for Gate

§

impl UnwindSafe for Gate

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.