snarkvm_console_types_boolean/
lib.rs1#![cfg_attr(test, allow(clippy::assertions_on_result_states))]
17#![warn(clippy::cast_possible_truncation)]
18
19mod bitwise;
20mod bytes;
21mod from_bits;
22mod parse;
23mod random;
24mod serialize;
25mod size_in_bits;
26mod size_in_bytes;
27mod to_bits;
28
29pub use snarkvm_console_network_environment::prelude::*;
30
31use core::marker::PhantomData;
32
33#[derive(Copy, Clone, PartialEq, Eq, Hash)]
34pub struct Boolean<E: Environment> {
35 boolean: bool,
37 _phantom: PhantomData<E>,
39}
40
41impl<E: Environment> BooleanTrait for Boolean<E> {}
42
43impl<E: Environment> Boolean<E> {
44 pub const fn new(boolean: bool) -> Self {
46 Self { boolean, _phantom: PhantomData }
47 }
48
49 #[deprecated(since = "0.1.0", note = "This is used for **testing** purposes")]
51 pub const fn zero() -> Self {
52 Self::new(false)
53 }
54}
55
56impl<E: Environment> TypeName for Boolean<E> {
57 #[inline]
59 fn type_name() -> &'static str {
60 "boolean"
61 }
62}
63
64impl<E: Environment> Deref for Boolean<E> {
65 type Target = bool;
66
67 #[inline]
68 fn deref(&self) -> &Self::Target {
69 &self.boolean
70 }
71}
72
73impl<E: Environment> PartialEq<Boolean<E>> for bool {
74 fn eq(&self, other: &Boolean<E>) -> bool {
75 *self == **other
76 }
77}