Skip to content

Commit b2ac741

Browse files
committed
Impl Rem for BoxedUint
1 parent c79ea4f commit b2ac741

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

src/uint/boxed/div.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! [`BoxedUint`] division operations.
22
33
use crate::{BoxedUint, Limb, NonZero};
4+
use core::ops::{Rem, RemAssign};
45
use subtle::ConstantTimeEq;
56

67
impl BoxedUint {
@@ -31,6 +32,54 @@ impl BoxedUint {
3132
}
3233
}
3334

35+
impl Rem<&NonZero<BoxedUint>> for &BoxedUint {
36+
type Output = BoxedUint;
37+
38+
#[inline]
39+
fn rem(self, rhs: &NonZero<BoxedUint>) -> Self::Output {
40+
self.rem_vartime(rhs)
41+
}
42+
}
43+
44+
impl Rem<&NonZero<BoxedUint>> for BoxedUint {
45+
type Output = BoxedUint;
46+
47+
#[inline]
48+
fn rem(self, rhs: &NonZero<BoxedUint>) -> Self::Output {
49+
self.rem_vartime(rhs)
50+
}
51+
}
52+
53+
impl Rem<NonZero<BoxedUint>> for &BoxedUint {
54+
type Output = BoxedUint;
55+
56+
#[inline]
57+
fn rem(self, rhs: NonZero<BoxedUint>) -> Self::Output {
58+
self.rem_vartime(&rhs)
59+
}
60+
}
61+
62+
impl Rem<NonZero<BoxedUint>> for BoxedUint {
63+
type Output = BoxedUint;
64+
65+
#[inline]
66+
fn rem(self, rhs: NonZero<BoxedUint>) -> Self::Output {
67+
self.rem_vartime(&rhs)
68+
}
69+
}
70+
71+
impl RemAssign<&NonZero<BoxedUint>> for BoxedUint {
72+
fn rem_assign(&mut self, rhs: &NonZero<BoxedUint>) {
73+
*self = self.rem_vartime(&rhs)
74+
}
75+
}
76+
77+
impl RemAssign<NonZero<BoxedUint>> for BoxedUint {
78+
fn rem_assign(&mut self, rhs: NonZero<BoxedUint>) {
79+
*self = self.rem_vartime(&rhs)
80+
}
81+
}
82+
3483
#[cfg(test)]
3584
mod tests {
3685
use super::{BoxedUint, NonZero};

0 commit comments

Comments
 (0)