Skip to content

Commit

Permalink
remove quote!
Browse files Browse the repository at this point in the history
Signed-off-by: Ruihang Xia <[email protected]>
  • Loading branch information
waynexia committed Jun 2, 2024
1 parent 8ab09e1 commit 33b69f8
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 27 deletions.
1 change: 0 additions & 1 deletion arrow-buffer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ bench = false
bytes = { version = "1.4" }
num = { version = "0.4", default-features = false, features = ["std"] }
half = { version = "2.1", default-features = false }
paste = { version = "1.0" }

[dev-dependencies]
criterion = { version = "0.5", default-features = false }
Expand Down
22 changes: 11 additions & 11 deletions arrow-buffer/src/arith.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/// Derives `std::ops::$t` for `$ty` calling `$wrapping` or `$checked` variants
/// based on if debug_assertions enabled
macro_rules! derive_arith {
($ty:ty, $t:ident, $op:ident, $wrapping:ident, $checked:ident) => {
($ty:ty, $t:ident, $t_assign:ident, $op:ident, $op_assign:ident, $wrapping:ident, $checked:ident) => {
impl std::ops::$t for $ty {
type Output = $ty;

Expand All @@ -34,17 +34,17 @@ macro_rules! derive_arith {
}
}

::paste::paste! {
impl std::ops::[< $t Assign >] for $ty {
#[cfg(debug_assertions)]
fn [< $op _assign >](&mut self, rhs: Self) {
*self = self.$checked(rhs).expect(concat!(stringify!($ty), " overflow"));
}
impl std::ops::$t_assign for $ty {
#[cfg(debug_assertions)]
fn $op_assign(&mut self, rhs: Self) {
*self = self
.$checked(rhs)
.expect(concat!(stringify!($ty), " overflow"));
}

#[cfg(not(debug_assertions))]
fn [< $op _assign >](&mut self, rhs: Self) {
*self = self.$wrapping(rhs);
}
#[cfg(not(debug_assertions))]
fn $op_assign(&mut self, rhs: Self) {
*self = self.$wrapping(rhs);
}
}

Expand Down
50 changes: 45 additions & 5 deletions arrow-buffer/src/bigint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,11 +639,51 @@ fn mulx(a: u128, b: u128) -> (u128, u128) {
(low, high)
}

derive_arith!(i256, Add, add, wrapping_add, checked_add);
derive_arith!(i256, Sub, sub, wrapping_sub, checked_sub);
derive_arith!(i256, Mul, mul, wrapping_mul, checked_mul);
derive_arith!(i256, Div, div, wrapping_div, checked_div);
derive_arith!(i256, Rem, rem, wrapping_rem, checked_rem);
derive_arith!(
i256,
Add,
AddAssign,
add,
add_assign,
wrapping_add,
checked_add
);
derive_arith!(
i256,
Sub,
SubAssign,
sub,
sub_assign,
wrapping_sub,
checked_sub
);
derive_arith!(
i256,
Mul,
MulAssign,
mul,
mul_assign,
wrapping_mul,
checked_mul
);
derive_arith!(
i256,
Div,
DivAssign,
div,
div_assign,
wrapping_div,
checked_div
);
derive_arith!(
i256,
Rem,
RemAssign,
rem,
rem_assign,
wrapping_rem,
checked_rem
);

impl Neg for i256 {
type Output = i256;
Expand Down
100 changes: 90 additions & 10 deletions arrow-buffer/src/interval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,51 @@ impl Neg for IntervalMonthDayNano {
}
}

derive_arith!(IntervalMonthDayNano, Add, add, wrapping_add, checked_add);
derive_arith!(IntervalMonthDayNano, Sub, sub, wrapping_sub, checked_sub);
derive_arith!(IntervalMonthDayNano, Mul, mul, wrapping_mul, checked_mul);
derive_arith!(IntervalMonthDayNano, Div, div, wrapping_div, checked_div);
derive_arith!(IntervalMonthDayNano, Rem, rem, wrapping_rem, checked_rem);
derive_arith!(
IntervalMonthDayNano,
Add,
AddAssign,
add,
add_assign,
wrapping_add,
checked_add
);
derive_arith!(
IntervalMonthDayNano,
Sub,
SubAssign,
sub,
sub_assign,
wrapping_sub,
checked_sub
);
derive_arith!(
IntervalMonthDayNano,
Mul,
MulAssign,
mul,
mul_assign,
wrapping_mul,
checked_mul
);
derive_arith!(
IntervalMonthDayNano,
Div,
DivAssign,
div,
div_assign,
wrapping_div,
checked_div
);
derive_arith!(
IntervalMonthDayNano,
Rem,
RemAssign,
rem,
rem_assign,
wrapping_rem,
checked_rem
);

/// Value of an IntervalDayTime array
#[derive(Debug, Default, Copy, Clone, Eq, PartialEq, Hash, Ord, PartialOrd)]
Expand Down Expand Up @@ -417,8 +457,48 @@ impl Neg for IntervalDayTime {
}
}

derive_arith!(IntervalDayTime, Add, add, wrapping_add, checked_add);
derive_arith!(IntervalDayTime, Sub, sub, wrapping_sub, checked_sub);
derive_arith!(IntervalDayTime, Mul, mul, wrapping_mul, checked_mul);
derive_arith!(IntervalDayTime, Div, div, wrapping_div, checked_div);
derive_arith!(IntervalDayTime, Rem, rem, wrapping_rem, checked_rem);
derive_arith!(
IntervalDayTime,
Add,
AddAssign,
add,
add_assign,
wrapping_add,
checked_add
);
derive_arith!(
IntervalDayTime,
Sub,
SubAssign,
sub,
sub_assign,
wrapping_sub,
checked_sub
);
derive_arith!(
IntervalDayTime,
Mul,
MulAssign,
mul,
mul_assign,
wrapping_mul,
checked_mul
);
derive_arith!(
IntervalDayTime,
Div,
DivAssign,
div,
div_assign,
wrapping_div,
checked_div
);
derive_arith!(
IntervalDayTime,
Rem,
RemAssign,
rem,
rem_assign,
wrapping_rem,
checked_rem
);

0 comments on commit 33b69f8

Please sign in to comment.