typed_sf/bit.rs
1/// Type-level enum of [`True`] and [`False`].
2pub trait Bit {
3 /// Result of negation of bit
4 type Neg: Bit;
5
6 /// `Real`, represented with rust's objects value of type.
7 fn val() -> bool;
8
9 /// `Real` value of type.
10 fn new() -> Self;
11}
12
13/// Type-level True value, [`Bit`].
14#[derive(Debug)]
15pub struct True;
16
17/// Type-level False value, [`Bit`].
18#[derive(Debug)]
19pub struct False;
20
21impl Bit for True {
22 type Neg = False;
23
24 #[inline]
25 fn val() -> bool {
26 true
27 }
28
29 #[inline]
30 fn new() -> Self {
31 True
32 }
33}
34
35impl Bit for False {
36 type Neg = True;
37
38 #[inline]
39 fn val() -> bool {
40 false
41 }
42
43 #[inline]
44 fn new() -> Self {
45 False
46 }
47}