pub trait Boolean:
Copy
+ Clone
+ Debug
+ Send
+ Sync
+ 'static
+ HasTypeWitness<BoolWitG<Self>> {
type Not: Boolean<Not = Self>;
type And<Rhs: Boolean>: Boolean;
type Or<Rhs: Boolean>: Boolean;
type Xor<Rhs: Boolean>: Boolean;
type IfTrue<Then, Else>;
type IfTrueB<Then: Boolean, Else: Boolean>: Boolean;
type IfTruePI<Then: PeanoInt, Else: PeanoInt>: PeanoInt;
const BOOL_WIT: BoolWitG<Self> = Self::WITNESS;
}Expand description
Trait for bounding type-level bools.
§Example
For an example that (indirectly) uses this trait, you can look at the module-level example
Provided Associated Constants§
Required Associated Types§
Sourcetype Not: Boolean<Not = Self>
type Not: Boolean<Not = Self>
Logical negation
§Example
use nlist::boolean::{self, Bool};
let _: boolean::Not<Bool<false>> = Bool::<true>;
let _: boolean::Not<Bool<true>> = Bool::<false>;
Sourcetype And<Rhs: Boolean>: Boolean
type And<Rhs: Boolean>: Boolean
Logical and
§Example
use nlist::boolean::{self, Bool};
let _: boolean::And<Bool<false>, Bool<false>> = Bool::<false>;
let _: boolean::And<Bool<false>, Bool<true>> = Bool::<false>;
let _: boolean::And<Bool<true>, Bool<false>> = Bool::<false>;
let _: boolean::And<Bool<true>, Bool<true>> = Bool::<true>;
Sourcetype Or<Rhs: Boolean>: Boolean
type Or<Rhs: Boolean>: Boolean
Logical or
§Example
use nlist::boolean::{self, Bool};
let _: boolean::Or<Bool<false>, Bool<false>> = Bool::<false>;
let _: boolean::Or<Bool<false>, Bool<true>> = Bool::<true>;
let _: boolean::Or<Bool<true>, Bool<false>> = Bool::<true>;
let _: boolean::Or<Bool<true>, Bool<true>> = Bool::<true>;
Sourcetype Xor<Rhs: Boolean>: Boolean
type Xor<Rhs: Boolean>: Boolean
Exclusive or
§Example
use nlist::boolean::{self, Bool};
let _: boolean::Xor<Bool<false>, Bool<false>> = Bool::<false>;
let _: boolean::Xor<Bool<false>, Bool<true>> = Bool::<true>;
let _: boolean::Xor<Bool<true>, Bool<false>> = Bool::<true>;
let _: boolean::Xor<Bool<true>, Bool<true>> = Bool::<false>;
Sourcetype IfTrue<Then, Else>
type IfTrue<Then, Else>
Evaluates to different types depending on the type of Self:
- if
Self == Bool<true>: evaluates toThen - if
Self == Bool<false>: evaluates toElse
§Example
use nlist::boolean::{self, Bool};
let _: boolean::IfTrue<Bool<false>, u8, u16> = 3u16;
let _: boolean::IfTrue<Bool<false>, u32, u64> = 5u64;
let _: boolean::IfTrue<Bool<true>, u8, u16> = 8u8;
let _: boolean::IfTrue<Bool<true>, u32, u64> = 13u32;
Sourcetype IfTrueB<Then: Boolean, Else: Boolean>: Boolean
type IfTrueB<Then: Boolean, Else: Boolean>: Boolean
Equivalent to IfTrue but only takes and returns Booleans
§Example
use nlist::boolean::{self, Bool};
let _: boolean::IfTrue<Bool<false>, Bool<false>, Bool<true>> = Bool::<true>;
let _: boolean::IfTrue<Bool<false>, Bool<true>, Bool<false>> = Bool::<false>;
let _: boolean::IfTrue<Bool<true>, Bool<false>, Bool<true>> = Bool::<false>;
let _: boolean::IfTrue<Bool<true>, Bool<true>, Bool<false>> = Bool::<true>;
Sourcetype IfTruePI<Then: PeanoInt, Else: PeanoInt>: PeanoInt
type IfTruePI<Then: PeanoInt, Else: PeanoInt>: PeanoInt
Equivalent to IfTrue but only takes and returns PeanoInts
§Example
use nlist::{Peano, peano};
use nlist::boolean::{self, Bool};
let _: boolean::IfTrue<Bool<false>, Peano!(3), Peano!(5)> = peano!(5);
let _: boolean::IfTrue<Bool<false>, Peano!(8), Peano!(13)> = peano!(13);
let _: boolean::IfTrue<Bool<true>, Peano!(3), Peano!(5)> = peano!(3);
let _: boolean::IfTrue<Bool<true>, Peano!(8), Peano!(13)> = peano!(8);
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.