This is an automated email from the ASF dual-hosted git repository.
tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/master by this push:
new 4c06f48de Implement Neg for i256 (#3151)
4c06f48de is described below
commit 4c06f48de6b835be68f45dffa4b58510cd07bb78
Author: Raphael Taylor-Davies <[email protected]>
AuthorDate: Mon Nov 21 18:05:36 2022 +0000
Implement Neg for i256 (#3151)
---
arrow-buffer/src/bigint.rs | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/arrow-buffer/src/bigint.rs b/arrow-buffer/src/bigint.rs
index be02c2857..23400b4a3 100644
--- a/arrow-buffer/src/bigint.rs
+++ b/arrow-buffer/src/bigint.rs
@@ -465,6 +465,20 @@ derive_op!(Mul, mul, wrapping_mul, checked_mul);
derive_op!(Div, div, wrapping_div, checked_div);
derive_op!(Rem, rem, wrapping_rem, checked_rem);
+impl std::ops::Neg for i256 {
+ type Output = i256;
+
+ #[cfg(debug_assertions)]
+ fn neg(self) -> Self::Output {
+ self.checked_neg().expect("i256 overflow")
+ }
+
+ #[cfg(not(debug_assertions))]
+ fn neg(self) -> Self::Output {
+ self.wrapping_neg()
+ }
+}
+
macro_rules! define_as_primitive {
($native_ty:ty) => {
impl AsPrimitive<i256> for $native_ty {