From ae585087603d8eecfeef2c241d51af0e3bd36aa0 Mon Sep 17 00:00:00 2001 From: pjh456 <147148383@qq.com> Date: Fri, 14 Aug 2026 05:26:35 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=B8=85=E7=90=86=20oxide=5Fbuiltins?= =?UTF-8?q?=20clippy=20=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/oxide_builtins/src/temporal.rs | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/crates/oxide_builtins/src/temporal.rs b/crates/oxide_builtins/src/temporal.rs index c2daa3f..ae057eb 100644 --- a/crates/oxide_builtins/src/temporal.rs +++ b/crates/oxide_builtins/src/temporal.rs @@ -1986,7 +1986,7 @@ pub fn duration_add(vm: &mut H, args: &[u8]) -> NativeResult { break; } let base = match unit { - 9 | 8 | 7 => 1_000, + 7..=9 => 1_000, 6 | 5 => 60, _ => 24, }; @@ -2088,7 +2088,7 @@ pub fn duration_round(vm: &mut H, args: &[u8]) -> NativeResult { native_try!(temporal_option_number(vm, increment_raw)) }; let increment = increment_value.trunc(); - if !increment.is_finite() || increment < 1.0 || increment > 1_000_000_000.0 { + if !increment.is_finite() || !(1.0..=1_000_000_000.0).contains(&increment) { return NativeResult::Err(crate::error::create_range_error(vm, "invalid rounding increment")); } let increment = increment as i128; @@ -2203,7 +2203,7 @@ pub fn duration_round(vm: &mut H, args: &[u8]) -> NativeResult { break; } let base = match unit { - 9 | 8 | 7 => 1_000, + 7..=9 => 1_000, 6 | 5 => 60, _ => 24, }; @@ -4122,34 +4122,22 @@ fn parse_difference_settings( let options = unsafe { &*options_ptr }; let largest_raw = match temporal_option_value(vm, options, options_value, "largestUnit") { Ok(raw) if raw.is_undefined() => None, - Ok(raw) => match temporal_option_string(vm, raw) { - Ok(value) => Some(value), - Err(error) => return Err(error), - }, + Ok(raw) => Some(temporal_option_string(vm, raw)?), Err(error) => return Err(error), }; let increment_raw = match temporal_option_value(vm, options, options_value, "roundingIncrement") { Ok(raw) if raw.is_undefined() => 1.0, - Ok(raw) => match temporal_option_number(vm, raw) { - Ok(value) => value, - Err(error) => return Err(error), - }, + Ok(raw) => temporal_option_number(vm, raw)?, Err(error) => return Err(error), }; let mode_raw = match temporal_option_value(vm, options, options_value, "roundingMode") { Ok(raw) if raw.is_undefined() => "trunc".to_string(), - Ok(raw) => match temporal_option_string(vm, raw) { - Ok(value) => value, - Err(error) => return Err(error), - }, + Ok(raw) => temporal_option_string(vm, raw)?, Err(error) => return Err(error), }; let smallest_raw = match temporal_option_value(vm, options, options_value, "smallestUnit") { Ok(raw) if raw.is_undefined() => default_smallest.to_string(), - Ok(raw) => match temporal_option_string(vm, raw) { - Ok(value) => value, - Err(error) => return Err(error), - }, + Ok(raw) => temporal_option_string(vm, raw)?, Err(error) => return Err(error), }; (largest_raw, increment_raw, mode_raw, smallest_raw)