pub enum LogicOp {
And,
Or,
Xor,
Nand,
Nor,
Xnor,
Not,
}Expand description
One of the combinational logic gates — kind=and/or/xor/nand/nor/xnor (N-input,
N >= 2) or kind=not (exactly 1 input). See LogicOp::call for the reduction rule.
Variants§
Implementations§
Source§impl LogicOp
impl LogicOp
pub fn from_name(name: &str) -> Option<Self>
Sourcepub fn name(self) -> &'static str
pub fn name(self) -> &'static str
The exact inverse of Self::from_name — see MathFn1::name’s own doc comment for why
this exists (naming this specific op for diagnostics, not the family as a whole).
Sourcepub fn is_unary(self) -> bool
pub fn is_unary(self) -> bool
true iff this op requires exactly one input (Not) rather than N >= 2.
Sourcepub fn call(self, inputs: &[bool]) -> bool
pub fn call(self, inputs: &[bool]) -> bool
Reduces inputs (already thresholded to bool by the caller, via as_bool) per this
op’s own rule:
And/Nand:true(negated forNand) iff every input istrue.Or/Nor:true(negated forNor) iff at least one input istrue.Xor/Xnor:true(negated forXnor) iff an odd number of inputs aretrue— the standard N-input generalization, not “exactly one” (which doesn’t generalize past two inputs in a way anyone actually expects).Not:inputsmust have exactly one element;trueiff it’sfalse.
§Panics
If Not is called with a slice that isn’t exactly length 1, or a non-Not op is called
with an empty slice — both unreachable in practice, since the caller (dae-runtime’s own
evaluate_blocks) already validates arity against Self::is_unary before calling this.
Trait Implementations§
impl Copy for LogicOp
impl Eq for LogicOp
impl StructuralPartialEq for LogicOp
Auto Trait Implementations§
impl Forget for LogicOp
impl Freeze for LogicOp
impl Move for LogicOp
impl RefUnwindSafe for LogicOp
impl Send for LogicOp
impl Sync for LogicOp
impl Unpin for LogicOp
impl UnsafeUnpin for LogicOp
impl UnwindSafe for LogicOp
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
Mutably borrows from an owned value. Read more