Skip to content

Commit aeffd20

Browse files
committed
wip
1 parent 297cf39 commit aeffd20

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

src/internal_type_traits.rs

+75
Original file line numberDiff line numberDiff line change
@@ -1 +1,76 @@
1+
use std::{
2+
fmt,
3+
iter::{Product, Sum},
4+
ops::{
5+
Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div,
6+
DivAssign, Mul, MulAssign, Not, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub,
7+
SubAssign,
8+
},
9+
};
110

11+
// Skipped:
12+
//
13+
// - `is_signed_int_t<T>` (probably won't be used directly in `modint.rs`)
14+
// - `is_unsigned_int_t<T>` (probably won't be used directly in `modint.rs`)
15+
// - `to_unsigned_t<T>` (not used in `fenwicktree.rs`)
16+
17+
// We will remove unnecessary bounds later.
18+
19+
/// Corresponds to `std::is_integral` in C++.
20+
pub(crate) trait Integral:
21+
'static
22+
+ Send
23+
+ Sync
24+
+ Copy
25+
+ Ord
26+
+ Not<Output = Self>
27+
+ Add<Output = Self>
28+
+ Sub<Output = Self>
29+
+ Mul<Output = Self>
30+
+ Div<Output = Self>
31+
+ Rem<Output = Self>
32+
+ AddAssign
33+
+ SubAssign
34+
+ MulAssign
35+
+ DivAssign
36+
+ RemAssign
37+
+ Sum
38+
+ Product
39+
+ BitOr<Output = Self>
40+
+ BitAnd<Output = Self>
41+
+ BitXor<Output = Self>
42+
+ BitOrAssign
43+
+ BitAndAssign
44+
+ BitXorAssign
45+
+ Shl<Output = Self>
46+
+ Shr<Output = Self>
47+
+ ShlAssign
48+
+ ShrAssign
49+
+ fmt::Display
50+
+ fmt::Debug
51+
+ fmt::Binary
52+
+ fmt::Octal
53+
{
54+
fn zero() -> Self;
55+
fn one() -> Self;
56+
}
57+
58+
macro_rules! impl_integral {
59+
($($ty:ty),*) => {
60+
$(
61+
impl Integral for $ty {
62+
#[inline]
63+
fn zero() -> Self {
64+
0
65+
}
66+
67+
#[inline]
68+
fn one() -> Self {
69+
0
70+
}
71+
}
72+
)*
73+
};
74+
}
75+
76+
impl_integral!(i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize);

0 commit comments

Comments
 (0)