tustvold commented on code in PR #2841:
URL: https://github.com/apache/arrow-rs/pull/2841#discussion_r990309851
##########
arrow/src/datatypes/native.rs:
##########
@@ -19,110 +19,72 @@ use crate::error::{ArrowError, Result};
pub use arrow_array::ArrowPrimitiveType;
pub use arrow_buffer::{ArrowNativeType, ToByteSlice};
use half::f16;
-use num::Zero;
-use std::ops::{Add, Div, Mul, Rem, Sub};
-mod private {
- pub trait Sealed {}
-}
-
-/// Trait for ArrowNativeType to provide overflow-checking and
non-overflow-checking
-/// variants for arithmetic operations. For floating point types, this
provides some
-/// default implementations. Integer types that need to deal with overflow can
implement
-/// this trait.
+/// Trait for [`ArrowNativeType`] that adds checked and unchecked arithmetic
operations,
+/// and totally ordered comparison operations
///
-/// The APIs with `_wrapping` suffix are the variant of non-overflow-checking.
If overflow
-/// occurred, they will supposedly wrap around the boundary of the type.
+/// The APIs with `_wrapping` suffix do not perform overflow-checking. For
integer
+/// types they will wrap around the boundary of the type. For floating point
types they
+/// will overflow to INF or -INF preserving the expected sign value
///
-/// The APIs with `_checked` suffix are the variant of overflow-checking which
return `None`
-/// if overflow occurred.
-pub trait ArrowNativeTypeOp:
- ArrowNativeType
- + Add<Output = Self>
- + Sub<Output = Self>
- + Mul<Output = Self>
- + Div<Output = Self>
- + Rem<Output = Self>
Review Comment:
Ensure might be too strong, but if writing a generic function using this as
a type constraint the default implementations won't be available. For example,
it caught that the SIMD kernels were using the default `%`
--
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]