viirya commented on code in PR #2756:
URL: https://github.com/apache/arrow-rs/pull/2756#discussion_r973648355


##########
arrow/src/datatypes/native.rs:
##########
@@ -102,6 +103,28 @@ pub(crate) mod native_op {
         fn div_wrapping(self, rhs: Self) -> Self {
             self / rhs
         }
+
+        /// Check `DivideByZero` error and `Overflow` error.
+        fn mod_fully_checked(self, rhs: Self) -> Result<Self> {
+            if rhs.is_zero() {
+                Err(ArrowError::DivideByZero)
+            } else {
+                Ok(self.mod_wrapping(rhs))
+            }
+        }
+
+        /// Only check `DivideByZero` error
+        fn mod_checked_divide_by_zero(self, rhs: Self) -> Result<Self> {

Review Comment:
   As you can see, it is very easy to do checking of division by zero only 
check (as did in `divide_opt`). Just need to do additional is_zero check along 
with calling wrapping API. Not to mention that this is special case (only 
divide and modulus). I don't see there is a need to add additional API there. I 
think it is better to keep a simple API instead of adding new ones when you can 
use existing APIs to do the same thing.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to