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 GelfondsConstant {
218 const GELFONDS_CONSTANT: Self;
219}
220
221pub trait GelfondSchneiderConstant {
223 const GELFOND_SCHNEIDER_CONSTANT: Self;
224}
225
226pub trait LemniscateConstant {
228 const LEMNISCATE_CONSTANT: Self;
229}
230
231pub trait RamanujansConstant {
233 const RAMANUJANS_CONSTANT: Self;
234}
235
236macro_rules! impl_non_zero {
240 ($($t:ident),+) => {
241 $(
242 impl One for $t {
243 const ONE: Self = match Self::new(1) {
244 Some(v) => v,
245 None => unreachable!() };
247 }
248
249 impl Two for $t {
250 const TWO: Self = match Self::new(2) {
251 Some(v) => v,
252 None => unreachable!() };
254 }
255 )+
256 };
257 ($($u:ident && $i:ident),+) => {
258 $(
259 impl_non_zero!($u, $i);
260
261 impl NegativeOne for $i {
262 const NEGATIVE_ONE: Self = match Self::new(-1) {
263 Some(v) => v,
264 None => unreachable!() };
266 }
267 )+
268 }
269}
270
271impl_non_zero!(
272 NonZeroUsize && NonZeroIsize,
273 NonZeroU128 && NonZeroI128,
274 NonZeroU64 && NonZeroI64,
275 NonZeroU32 && NonZeroI32,
276 NonZeroU16 && NonZeroI16,
277 NonZeroU8 && NonZeroI8
278);