From 1fe105f58c067ed90aac8a7acbf0e5cec0a427ab Mon Sep 17 00:00:00 2001 From: Solomon Ucko Date: Tue, 9 Aug 2022 20:43:15 -0400 Subject: [PATCH] stub implementation of Div and DivAssign for SmallInt and SmallUint --- src/ops.rs | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/src/ops.rs b/src/ops.rs index e9e8246..b2ae78b 100644 --- a/src/ops.rs +++ b/src/ops.rs @@ -1,8 +1,8 @@ use crate::smallint::{SmallIntType, SmallUintType}; use crate::{SmallInt, SmallUint}; use core::mem::ManuallyDrop; -use core::ops::{Add, Mul, Neg, Sub}; -use core::ops::{AddAssign, MulAssign, SubAssign}; +use core::ops::{Add, Div, Mul, Neg, Sub}; +use core::ops::{AddAssign, DivAssign, MulAssign, SubAssign}; impl Neg for SmallInt { type Output = Self; @@ -581,3 +581,39 @@ impl MulAssign for SmallInt { *self = self.clone() * rhs; } } + +fn div(a: &SmallUint, b: &SmallUint) -> SmallUint { + todo!() +} + +basic_op!(Div, div, SmallUint, div); + +impl<'a> DivAssign<&'a SmallUint> for SmallUint { + fn div_assign(&mut self, rhs: &'a SmallUint) { + *self = self.clone() / rhs; + } +} + +impl DivAssign for SmallUint { + fn div_assign(&mut self, rhs: SmallUint) { + *self = self.clone() / rhs; + } +} + +fn div_signed(a: &SmallInt, b: &SmallInt) -> SmallInt { + todo!() +} + +basic_op!(Div, div, SmallInt, div_signed); + +impl<'a> DivAssign<&'a SmallInt> for SmallInt { + fn div_assign(&mut self, rhs: &'a SmallInt) { + *self = self.clone() / rhs; + } +} + +impl DivAssign for SmallInt { + fn div_assign(&mut self, rhs: SmallInt) { + *self = self.clone() / rhs; + } +} \ No newline at end of file