diff --git a/arrow-cast/src/cast.rs b/arrow-cast/src/cast.rs index a6b3489d9f07..54c500f1ac41 100644 --- a/arrow-cast/src/cast.rs +++ b/arrow-cast/src/cast.rs @@ -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) @@ -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)