tustvold commented on code in PR #5769:
URL: https://github.com/apache/arrow-rs/pull/5769#discussion_r1602069374


##########
arrow-buffer/src/interval.rs:
##########
@@ -0,0 +1,407 @@
+use crate::arith::derive_arith;
+use std::ops::Neg;
+
+/// Value of an IntervalMonthDayNano array
+#[derive(Debug, Default, Copy, Clone, Eq, PartialEq, Hash, Ord, PartialOrd)]
+#[repr(C)]
+pub struct IntervalMonthDayNano {
+    pub months: i32,
+    pub days: i32,
+    pub nanoseconds: i64,
+}
+
+impl IntervalMonthDayNano {
+    /// The additive identity i.e. `0`.
+    pub const ZERO: Self = Self::new(0, 0, 0);
+
+    /// The multiplicative identity, i.e. `1`.
+    pub const ONE: Self = Self::new(1, 1, 1);
+
+    /// The multiplicative inverse, i.e. `-1`.
+    pub const MINUS_ONE: Self = Self::new(-1, -1, -1);
+
+    /// The maximum value that can be represented
+    pub const MAX: Self = Self::new(i32::MAX, i32::MAX, i64::MAX);
+
+    /// The minimum value that can be represented
+    pub const MIN: Self = Self::new(i32::MIN, i32::MIN, i64::MIN);
+
+    /// Create a new [`IntervalMonthDayNano`]
+    #[inline]
+    pub const fn new(months: i32, days: i32, nanoseconds: i64) -> Self {
+        Self {
+            months,
+            days,
+            nanoseconds,
+        }
+    }
+
+    /// Computes the absolute value
+    #[inline]
+    pub fn wrapping_abs(self) -> Self {

Review Comment:
   These arithmetic operations are a little odd, but it's necessary to 
implement them in order to keep the type machinery happy



-- 
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