nightly_quirks/
int_roundings.rs1pub trait IntRoundings {
2 fn nq_div_ceil(self, rhs: Self) -> Self;
3}
4
5macro_rules! int_roundings {
6 ($int_type:ty) => {
7 impl IntRoundings for $int_type {
8 #[must_use = "this returns the result of the operation, \
9 without modifying the original"]
10 #[inline]
11 fn nq_div_ceil(self, rhs: Self) -> Self {
12 let d = self / rhs;
13 let r = self % rhs;
14 if r > 0 && rhs > 0 {
15 d + 1
16 } else {
17 d
18 }
19 }
20 }
21 };
22}
23
24int_roundings!(u8);
25int_roundings!(i8);
26int_roundings!(u16);
27int_roundings!(i16);
28int_roundings!(u32);
29int_roundings!(i32);
30int_roundings!(u64);
31int_roundings!(i64);
32int_roundings!(u128);
33int_roundings!(i128);