Rafferty97 commented on code in PR #9418:
URL: https://github.com/apache/arrow-rs/pull/9418#discussion_r2957071389
##########
arrow-buffer/src/bigint/mod.rs:
##########
@@ -807,6 +807,53 @@ impl Shr<u8> for i256 {
}
}
+impl WrappingShl for i256 {
+ #[inline]
+ fn wrapping_shl(&self, rhs: u32) -> i256 {
+ // Mask the higher-order bits
+ (*self).shl(rhs as u8)
+ }
+}
+
+impl WrappingShr for i256 {
+ #[inline]
+ fn wrapping_shr(&self, rhs: u32) -> i256 {
+ // Masks the higher-order bits
+ (*self).shr(rhs as u8)
+ }
+}
+
+// Define Shl<T> and Shr<T> for specified integer types using
+// an existing Shl<u8> and Shr<u8> implementation
+macro_rules! define_standard_shift {
+ // Handle multiple types
+ ($trait_name:ident, $method:ident, [$($t:ty),+]) => {
+ $(define_standard_shift!($trait_name, $method, $t);)+
+ };
+ // Handle single type
+ ($trait_name:ident, $method:ident, $t:ty) => {
+ impl $trait_name<$t> for i256 {
+ type Output = i256;
+
+ #[inline]
+ fn $method(self, rhs: $t) -> Self::Output {
+ self.$method(rhs as u8)
Review Comment:
This won't panic as expected. Instead use `u8::try_from(rhs).expect("...")`.
##########
arrow-buffer/src/bigint/mod.rs:
##########
@@ -1535,6 +1592,20 @@ mod tests {
assert_eq!(<i256 as Bounded>::max_value(), i256::MAX);
}
+ #[test]
Review Comment:
You can use `#[should_panic]` here
--
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]