Skip to content

Commit

Permalink
For review
Browse files Browse the repository at this point in the history
  • Loading branch information
viirya committed Sep 27, 2023
1 parent fcfc957 commit dd5558c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions arrow-cast/src/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,8 @@ where
if cast_options.safe {
array
.unary_opt::<_, Decimal128Type>(|v| {
(mul * v.as_()).round().to_i128().and_then(|v| {
(Decimal128Type::validate_decimal_precision(v, precision).is_ok())
.then_some(v)
(mul * v.as_()).round().to_i128().filter(|v| {
Decimal128Type::validate_decimal_precision(*v, precision).is_ok()
})
})
.with_precision_and_scale(precision, scale)
Expand Down Expand Up @@ -411,9 +410,8 @@ where
if cast_options.safe {
array
.unary_opt::<_, Decimal256Type>(|v| {
i256::from_f64((v.as_() * mul).round()).and_then(|v| {
(Decimal256Type::validate_decimal_precision(v, precision).is_ok())
.then_some(v)
i256::from_f64((v.as_() * mul).round()).filter(|v| {
Decimal256Type::validate_decimal_precision(*v, precision).is_ok()
})
})
.with_precision_and_scale(precision, scale)
Expand Down

0 comments on commit dd5558c

Please sign in to comment.