rithm/fraction/
zeroable.rs1use crate::big_int::BigInt;
2use traiter::numbers::Zeroable;
3
4use super::types::Fraction;
5
6impl<'a, Digit, const DIGIT_BITNESS: usize> Zeroable
7 for &'a Fraction<BigInt<Digit, DIGIT_BITNESS>>
8where
9 &'a BigInt<Digit, DIGIT_BITNESS>: Zeroable,
10{
11 fn is_zero(self) -> bool {
12 (&self.numerator).is_zero()
13 }
14}
15
16impl<Digit, const DIGIT_BITNESS: usize> Zeroable
17 for Fraction<BigInt<Digit, DIGIT_BITNESS>>
18where
19 BigInt<Digit, DIGIT_BITNESS>: Zeroable,
20{
21 fn is_zero(self) -> bool {
22 self.numerator.is_zero()
23 }
24}
25
26macro_rules! integer_fraction_zeroable_impl {
27 ($($integer:ty)*) => ($(
28 impl Zeroable for &Fraction<$integer> {
29 fn is_zero(self) -> bool {
30 self.numerator.is_zero()
31 }
32 }
33
34 impl Zeroable for Fraction<$integer> {
35 fn is_zero(self) -> bool {
36 self.numerator.is_zero()
37 }
38 }
39 )*)
40}
41
42integer_fraction_zeroable_impl!(
43 i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize
44);