Skip to main content

relp_num/rational/big/
with_zero.rs

1use std::ops::{Add, AddAssign, Mul, MulAssign, Sub, SubAssign};
2
3use crate::rational::big::Big;
4use crate::fixed::Zero;
5
6impl<const S: usize> From<Zero> for Big<S> {
7    #[inline]
8    fn from(_: Zero) -> Self {
9        num_traits::Zero::zero()
10    }
11}
12
13impl<const S: usize> From<&Zero> for Big<S> {
14    #[inline]
15    fn from(_: &Zero) -> Self {
16        num_traits::Zero::zero()
17    }
18}
19
20impl<const S: usize> Add<Zero> for Big<S> {
21    type Output = Self;
22
23    #[inline]
24    fn add(self, _: Zero) -> Self::Output {
25        self
26    }
27}
28
29impl<const S: usize> Add<&Zero> for Big<S> {
30    type Output = Self;
31
32    #[inline]
33    fn add(self, _: &Zero) -> Self::Output {
34        self
35    }
36}
37
38impl<const S: usize> AddAssign<Zero> for Big<S> {
39    #[inline]
40    fn add_assign(&mut self, _: Zero) {
41    }
42}
43
44impl<const S: usize> AddAssign<&Zero> for Big<S> {
45    #[inline]
46    fn add_assign(&mut self, _: &Zero) {
47    }
48}
49
50impl<const S: usize> Sub<Zero> for Big<S> {
51    type Output = Self;
52
53    #[inline]
54    fn sub(self, _: Zero) -> Self::Output {
55        self
56    }
57}
58
59impl<const S: usize> Sub<&Zero> for Big<S> {
60    type Output = Self;
61
62    #[inline]
63    fn sub(self, _: &Zero) -> Self::Output {
64        self
65    }
66}
67
68impl<const S: usize> SubAssign<Zero> for Big<S> {
69    #[inline]
70    fn sub_assign(&mut self, _: Zero) {
71    }
72}
73
74impl<const S: usize> SubAssign<&Zero> for Big<S> {
75    #[inline]
76    fn sub_assign(&mut self, _: &Zero) {
77    }
78}
79
80impl<const S: usize> Mul<Zero> for Big<S> {
81    type Output = Self;
82
83    #[inline]
84    fn mul(mut self, _: Zero) -> Self::Output {
85        MulAssign::mul_assign(&mut self, Zero);
86        self
87    }
88}
89
90impl<const S: usize> Mul<&Zero> for Big<S> {
91    type Output = Self;
92
93    #[inline]
94    fn mul(mut self, _: &Zero) -> Self::Output {
95        MulAssign::mul_assign(&mut self, Zero);
96        self
97    }
98}
99
100impl<const S: usize> Mul<Zero> for &Big<S> {
101    type Output = Big<S>;
102
103    #[inline]
104    fn mul(self, _: Zero) -> Self::Output {
105        num_traits::Zero::zero()
106    }
107}
108
109impl<const S: usize> Mul<&Zero> for &Big<S> {
110    type Output = Big<S>;
111
112    #[inline]
113    fn mul(self, _: &Zero) -> Self::Output {
114        num_traits::Zero::zero()
115    }
116}
117
118impl<const S: usize> MulAssign<Zero> for Big<S> {
119    #[inline]
120    fn mul_assign(&mut self, _: Zero) {
121        MulAssign::mul_assign(self, &Zero);
122    }
123}
124
125impl<const S: usize> MulAssign<&Zero> for Big<S> {
126    #[inline]
127    fn mul_assign(&mut self, _: &Zero) {
128        num_traits::Zero::set_zero(self);
129    }
130}