1pub trait MulCeil<Rhs = Self> {
5 type Output;
6
7 fn mul_ceil(self, rhs: Rhs) -> Self::Output;
8}
9
10impl MulCeil for f64 {
11 type Output = f64;
12
13 fn mul_ceil(self, rhs: f64) -> f64 {
14 (self * rhs).ceil()
15 }
16}
17
18#[macro_export]
19macro_rules! impl_mul_ceil {
20 ($($name:ident),+ $(,)?) => {
21 $(
22 impl $crate::ops::MulCeil<f64> for $name {
23 type Output = f64;
24
25 fn mul_ceil(self, rhs: f64) -> Self::Output {
26 (f64::from(self) * rhs).ceil()
27 }
28 }
29
30 impl $crate::ops::MulCeil<$name> for f64 {
31 type Output = f64;
32
33 fn mul_ceil(self, rhs: $name) -> Self::Output {
34 (self * f64::from(rhs)).ceil()
35 }
36 }
37 )+
38 };
39}
40
41impl_mul_ceil!(i8, u8, i16, u16, i32, u32, f32);