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)]
42pub trait I {
43 const I: Self;
44}
45
46#[allow(clippy::declare_interior_mutable_const)]
51pub trait NegativeI {
52 const NEGATIVE_I: Self;
53}
54
55#[allow(clippy::declare_interior_mutable_const)]
57pub trait OneHalf {
58 const ONE_HALF: Self;
59}
60
61#[allow(clippy::declare_interior_mutable_const)]
63pub trait NegativeZero {
64 const NEGATIVE_ZERO: Self;
65}
66
67#[allow(clippy::declare_interior_mutable_const)]
69pub trait Infinity {
70 const INFINITY: Self;
71}
72
73#[allow(clippy::declare_interior_mutable_const)]
75pub trait NegativeInfinity {
76 const NEGATIVE_INFINITY: Self;
77}
78
79#[allow(clippy::declare_interior_mutable_const)]
81pub trait NaN {
82 const NAN: Self;
83}
84
85pub trait ProuhetThueMorseConstant {
87 const PROUHET_THUE_MORSE_CONSTANT: Self;
88}
89
90pub trait PrimeConstant {
93 const PRIME_CONSTANT: Self;
94}
95
96pub trait Ln2 {
98 const LN_2: Self;
99}
100
101pub trait Ln10 {
103 const LN_10: Self;
104}
105
106pub trait Log2E {
108 const LOG_2_E: Self;
109}
110
111pub trait Log10E {
113 const LOG_10_E: Self;
114}
115
116pub trait Log210 {
118 const LOG_2_10: Self;
119}
120
121pub trait Log102 {
123 const LOG_10_2: Self;
124}
125
126pub trait Sqrt2 {
128 const SQRT_2: Self;
129}
130
131pub trait Sqrt3 {
133 const SQRT_3: Self;
134}
135
136pub trait Sqrt5 {
138 const SQRT_5: Self;
139}
140
141pub trait Sqrt2Over2 {
143 const SQRT_2_OVER_2: Self;
144}
145
146pub trait Sqrt3Over3 {
148 const SQRT_3_OVER_3: Self;
149}
150
151pub trait Sqrt5Over5 {
153 const SQRT_5_OVER_5: Self;
154}
155
156pub trait Phi {
158 const PHI: Self;
159}
160
161pub trait Pi {
163 const PI: Self;
164}
165
166pub trait Tau {
168 const TAU: Self;
169}
170
171pub trait PiOver2 {
173 const PI_OVER_2: Self;
174}
175
176pub trait PiOver3 {
178 const PI_OVER_3: Self;
179}
180
181pub trait PiOver4 {
183 const PI_OVER_4: Self;
184}
185
186pub trait PiOver6 {
188 const PI_OVER_6: Self;
189}
190
191pub trait PiOver8 {
193 const PI_OVER_8: Self;
194}
195
196pub trait OneOverPi {
198 const ONE_OVER_PI: Self;
199}
200
201pub trait SqrtPi {
203 const SQRT_PI: Self;
204}
205
206pub trait OneOverSqrtPi {
208 const ONE_OVER_SQRT_PI: Self;
209}
210
211pub trait OneOverSqrtTau {
213 const ONE_OVER_SQRT_TAU: Self;
214}
215
216pub trait TwoOverPi {
218 const TWO_OVER_PI: Self;
219}
220
221pub trait TwoOverSqrtPi {
223 const TWO_OVER_SQRT_PI: Self;
224}
225
226pub trait CatalansConstant {
228 const CATALANS_CONSTANT: Self;
229}
230
231pub trait ChampernowneConstant {
234 const CHAMPERNOWNE_CONSTANT: Self;
235}
236
237pub trait CopelandErdosConstant {
240 const COPELAND_ERDOS_CONSTANT: Self;
241}
242
243pub trait EulersConstant {
246 const EULERS_CONSTANT: Self;
247}
248
249pub trait GaussConstant {
254 const GAUSS_CONSTANT: Self;
255}
256
257pub trait DottieNumber {
260 const DOTTIE_NUMBER: Self;
261}
262
263pub trait GelfondsConstant {
265 const GELFONDS_CONSTANT: Self;
266}
267
268pub trait GelfondSchneiderConstant {
270 const GELFOND_SCHNEIDER_CONSTANT: Self;
271}
272
273pub trait LemniscateConstant {
275 const LEMNISCATE_CONSTANT: Self;
276}
277
278pub trait LiouvillesConstant {
281 const LIOUVILLES_CONSTANT: Self;
282}
283
284pub trait RamanujansConstant {
286 const RAMANUJANS_CONSTANT: Self;
287}
288
289macro_rules! impl_non_zero {
293 ($($t:ident),+) => {
294 $(
295 impl One for $t {
296 const ONE: Self = match Self::new(1) {
297 Some(v) => v,
298 None => unreachable!() };
300 }
301
302 impl Two for $t {
303 const TWO: Self = match Self::new(2) {
304 Some(v) => v,
305 None => unreachable!() };
307 }
308 )+
309 };
310 ($($u:ident && $i:ident),+) => {
311 $(
312 impl_non_zero!($u, $i);
313
314 impl NegativeOne for $i {
315 const NEGATIVE_ONE: Self = match Self::new(-1) {
316 Some(v) => v,
317 None => unreachable!() };
319 }
320 )+
321 }
322}
323
324impl_non_zero!(
325 NonZeroUsize && NonZeroIsize,
326 NonZeroU128 && NonZeroI128,
327 NonZeroU64 && NonZeroI64,
328 NonZeroU32 && NonZeroI32,
329 NonZeroU16 && NonZeroI16,
330 NonZeroU8 && NonZeroI8
331);