malachite_base/num/basic/
traits.rs1use core::num::*;
12
13#[allow(clippy::declare_interior_mutable_const)]
15pub trait Zero {
16 const ZERO: Self;
17}
18
19#[allow(clippy::declare_interior_mutable_const)]
21pub trait One {
22 const ONE: Self;
23}
24
25#[allow(clippy::declare_interior_mutable_const)]
27pub trait Two {
28 const TWO: Self;
29}
30
31#[allow(clippy::declare_interior_mutable_const)]
33pub trait NegativeOne {
34 const NEGATIVE_ONE: Self;
35}
36
37#[allow(clippy::declare_interior_mutable_const)]
39pub trait OneHalf {
40 const ONE_HALF: Self;
41}
42
43#[allow(clippy::declare_interior_mutable_const)]
45pub trait NegativeZero {
46 const NEGATIVE_ZERO: Self;
47}
48
49#[allow(clippy::declare_interior_mutable_const)]
51pub trait Infinity {
52 const INFINITY: Self;
53}
54
55#[allow(clippy::declare_interior_mutable_const)]
57pub trait NegativeInfinity {
58 const NEGATIVE_INFINITY: Self;
59}
60
61#[allow(clippy::declare_interior_mutable_const)]
63pub trait NaN {
64 const NAN: Self;
65}
66
67pub trait ProuhetThueMorseConstant {
69 const PROUHET_THUE_MORSE_CONSTANT: Self;
70}
71
72pub trait PrimeConstant {
75 const PRIME_CONSTANT: Self;
76}
77
78pub trait Ln2 {
80 const LN_2: Self;
81}
82
83pub trait Ln10 {
85 const LN_10: Self;
86}
87
88pub trait Log2E {
90 const LOG_2_E: Self;
91}
92
93pub trait Log10E {
95 const LOG_10_E: Self;
96}
97
98pub trait Log210 {
100 const LOG_2_10: Self;
101}
102
103pub trait Log102 {
105 const LOG_10_2: Self;
106}
107
108pub trait Sqrt2 {
110 const SQRT_2: Self;
111}
112
113pub trait Sqrt3 {
115 const SQRT_3: Self;
116}
117
118pub trait Sqrt5 {
120 const SQRT_5: Self;
121}
122
123pub trait Sqrt2Over2 {
125 const SQRT_2_OVER_2: Self;
126}
127
128pub trait Sqrt3Over3 {
130 const SQRT_3_OVER_3: Self;
131}
132
133pub trait Sqrt5Over5 {
135 const SQRT_5_OVER_5: Self;
136}
137
138pub trait Phi {
140 const PHI: Self;
141}
142
143pub trait Pi {
145 const PI: Self;
146}
147
148pub trait Tau {
150 const TAU: Self;
151}
152
153pub trait PiOver2 {
155 const PI_OVER_2: Self;
156}
157
158pub trait PiOver3 {
160 const PI_OVER_3: Self;
161}
162
163pub trait PiOver4 {
165 const PI_OVER_4: Self;
166}
167
168pub trait PiOver6 {
170 const PI_OVER_6: Self;
171}
172
173pub trait PiOver8 {
175 const PI_OVER_8: Self;
176}
177
178pub trait OneOverPi {
180 const ONE_OVER_PI: Self;
181}
182
183pub trait SqrtPi {
185 const SQRT_PI: Self;
186}
187
188pub trait OneOverSqrtPi {
190 const ONE_OVER_SQRT_PI: Self;
191}
192
193pub trait OneOverSqrtTau {
195 const ONE_OVER_SQRT_TAU: Self;
196}
197
198pub trait TwoOverPi {
200 const TWO_OVER_PI: Self;
201}
202
203pub trait TwoOverSqrtPi {
205 const TWO_OVER_SQRT_PI: Self;
206}
207
208pub trait GaussConstant {
213 const GAUSS_CONSTANT: Self;
214}
215
216pub trait LemniscateConstant {
218 const LEMNISCATE_CONSTANT: Self;
219}
220
221macro_rules! impl_non_zero {
225 ($($t:ident),+) => {
226 $(
227 impl One for $t {
228 const ONE: Self = match Self::new(1) {
229 Some(v) => v,
230 None => unreachable!() };
232 }
233
234 impl Two for $t {
235 const TWO: Self = match Self::new(2) {
236 Some(v) => v,
237 None => unreachable!() };
239 }
240 )+
241 };
242 ($($u:ident && $i:ident),+) => {
243 $(
244 impl_non_zero!($u, $i);
245
246 impl NegativeOne for $i {
247 const NEGATIVE_ONE: Self = match Self::new(-1) {
248 Some(v) => v,
249 None => unreachable!() };
251 }
252 )+
253 }
254}
255
256impl_non_zero!(
257 NonZeroUsize && NonZeroIsize,
258 NonZeroU128 && NonZeroI128,
259 NonZeroU64 && NonZeroI64,
260 NonZeroU32 && NonZeroI32,
261 NonZeroU16 && NonZeroI16,
262 NonZeroU8 && NonZeroI8
263);