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 CatalansConstant {
210 const CATALANS_CONSTANT: Self;
211}
212
213pub trait ChampernowneConstant {
216 const CHAMPERNOWNE_CONSTANT: Self;
217}
218
219pub trait CopelandErdosConstant {
222 const COPELAND_ERDOS_CONSTANT: Self;
223}
224
225pub trait EulersConstant {
228 const EULERS_CONSTANT: Self;
229}
230
231pub trait GaussConstant {
236 const GAUSS_CONSTANT: Self;
237}
238
239pub trait GelfondsConstant {
241 const GELFONDS_CONSTANT: Self;
242}
243
244pub trait GelfondSchneiderConstant {
246 const GELFOND_SCHNEIDER_CONSTANT: Self;
247}
248
249pub trait LemniscateConstant {
251 const LEMNISCATE_CONSTANT: Self;
252}
253
254pub trait LiouvillesConstant {
257 const LIOUVILLES_CONSTANT: Self;
258}
259
260pub trait RamanujansConstant {
262 const RAMANUJANS_CONSTANT: Self;
263}
264
265macro_rules! impl_non_zero {
269 ($($t:ident),+) => {
270 $(
271 impl One for $t {
272 const ONE: Self = match Self::new(1) {
273 Some(v) => v,
274 None => unreachable!() };
276 }
277
278 impl Two for $t {
279 const TWO: Self = match Self::new(2) {
280 Some(v) => v,
281 None => unreachable!() };
283 }
284 )+
285 };
286 ($($u:ident && $i:ident),+) => {
287 $(
288 impl_non_zero!($u, $i);
289
290 impl NegativeOne for $i {
291 const NEGATIVE_ONE: Self = match Self::new(-1) {
292 Some(v) => v,
293 None => unreachable!() };
295 }
296 )+
297 }
298}
299
300impl_non_zero!(
301 NonZeroUsize && NonZeroIsize,
302 NonZeroU128 && NonZeroI128,
303 NonZeroU64 && NonZeroI64,
304 NonZeroU32 && NonZeroI32,
305 NonZeroU16 && NonZeroI16,
306 NonZeroU8 && NonZeroI8
307);