pub enum Tribool {
True,
False,
Indeterminate,
}
Expand description
Three-state Boolean logic
Variants§
Implementations§
Source§impl Tribool
impl Tribool
Sourcepub const fn boolean(value: bool) -> Tribool
pub const fn boolean(value: bool) -> Tribool
Construct a new non-indeterminate Tribool from a regular boolean value
Sourcepub const fn is_indeterminate(self) -> bool
pub const fn is_indeterminate(self) -> bool
Returns true
only if self
is Indeterminate
§Example
assert!(Tribool::Indeterminate.is_indeterminate())
Sourcepub const fn equals(self, rhs: Tribool) -> Tribool
pub const fn equals(self, rhs: Tribool) -> Tribool
Checks for equality of two Tribool
s,
returning Indeterminate
if either are indeterminate.
§Example
assert!(Tribool::True.equals(Tribool::True).is_true());
assert!(Tribool::True.equals(Tribool::False).is_false());
assert!(Tribool::Indeterminate.equals(Tribool::False).is_indeterminate())
Sourcepub const fn not_equals(self, rhs: Tribool) -> Tribool
pub const fn not_equals(self, rhs: Tribool) -> Tribool
Checks for inequality of two Tribool
s,
returning Indeterminate
if either are indeterminate.
§Example
assert!(Tribool::True.not_equals(Tribool::True).is_false());
assert!(Tribool::True.not_equals(Tribool::False).is_true());
assert!(Tribool::Indeterminate.not_equals(Tribool::False).is_indeterminate())
Sourcepub const fn kleene_implication(self, b: Tribool) -> Tribool
pub const fn kleene_implication(self, b: Tribool) -> Tribool
Material implication using Kleene Logic.
This is equivalent to NOT(A) OR B
.
Sourcepub fn lukasiewicz_implication(self, b: Tribool) -> Tribool
pub fn lukasiewicz_implication(self, b: Tribool) -> Tribool
Material implication using Łukasiewicz Logic
The Łukasiewicz Ł3 has the same tables for AND, OR, and NOT as the Kleene logic used elsewhere, but differs in its definition of implication in that “unknown implies unknown” is true.
For more information, see the Wikipedia page and the section on Łukasiewicz Logic
Trait Implementations§
Source§impl<B: Into<Tribool>> BitAndAssign<B> for Tribool
impl<B: Into<Tribool>> BitAndAssign<B> for Tribool
Source§fn bitand_assign(&mut self, rhs: B)
fn bitand_assign(&mut self, rhs: B)
Performs the
&=
operation. Read moreSource§impl BitAndAssign<Tribool> for bool
impl BitAndAssign<Tribool> for bool
Source§fn bitand_assign(&mut self, rhs: Tribool)
fn bitand_assign(&mut self, rhs: Tribool)
Performs the
&=
operation. Read moreSource§impl<B: Into<Tribool>> BitOrAssign<B> for Tribool
impl<B: Into<Tribool>> BitOrAssign<B> for Tribool
Source§fn bitor_assign(&mut self, rhs: B)
fn bitor_assign(&mut self, rhs: B)
Performs the
|=
operation. Read moreSource§impl BitOrAssign<Tribool> for bool
impl BitOrAssign<Tribool> for bool
Source§fn bitor_assign(&mut self, rhs: Tribool)
fn bitor_assign(&mut self, rhs: Tribool)
Performs the
|=
operation. Read moreSource§impl<B: Into<Tribool>> BitXorAssign<B> for Tribool
impl<B: Into<Tribool>> BitXorAssign<B> for Tribool
Source§fn bitxor_assign(&mut self, rhs: B)
fn bitxor_assign(&mut self, rhs: B)
Performs the
^=
operation. Read moreSource§impl BitXorAssign<Tribool> for bool
impl BitXorAssign<Tribool> for bool
Source§fn bitxor_assign(&mut self, rhs: Tribool)
fn bitxor_assign(&mut self, rhs: Tribool)
Performs the
^=
operation. Read moreSource§impl<B: Into<Tribool> + Copy> PartialOrd<B> for Tribool
impl<B: Into<Tribool> + Copy> PartialOrd<B> for Tribool
impl Copy for Tribool
Auto Trait Implementations§
impl Freeze for Tribool
impl RefUnwindSafe for Tribool
impl Send for Tribool
impl Sync for Tribool
impl Unpin for Tribool
impl UnwindSafe for Tribool
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