pub struct TruthTable {
pub entries: [TruthTableEntry; 4],
pub name: &'static str,
}Expand description
A complete truth table for a 2-input boolean function.
Fields§
§entries: [TruthTableEntry; 4]All four entries (FF, FT, TF, TT).
name: &'static strName of the operation.
Implementations§
Source§impl TruthTable
impl TruthTable
Sourcepub fn compute(name: &'static str, f: fn(bool, bool) -> bool) -> Self
pub fn compute(name: &'static str, f: fn(bool, bool) -> bool) -> Self
Compute the truth table for a given 2-input function.
Sourcepub fn is_commutative(&self) -> bool
pub fn is_commutative(&self) -> bool
Check if the function is commutative: f(a,b) == f(b,a) for all inputs.
Sourcepub fn is_tautology(&self) -> bool
pub fn is_tautology(&self) -> bool
Check if the function always returns true (tautology).
Sourcepub fn is_contradiction(&self) -> bool
pub fn is_contradiction(&self) -> bool
Check if the function always returns false (contradiction).
Sourcepub fn true_count(&self) -> usize
pub fn true_count(&self) -> usize
Count the number of true outputs.
Trait Implementations§
Source§impl Clone for TruthTable
impl Clone for TruthTable
Source§fn clone(&self) -> TruthTable
fn clone(&self) -> TruthTable
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TruthTable
impl RefUnwindSafe for TruthTable
impl Send for TruthTable
impl Sync for TruthTable
impl Unpin for TruthTable
impl UnsafeUnpin for TruthTable
impl UnwindSafe for TruthTable
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