From f6b8fda19d06712456e884491551482dd0841d15 Mon Sep 17 00:00:00 2001 From: Lucas Colombo Date: Mon, 27 May 2024 06:32:09 -0300 Subject: [PATCH] =?UTF-8?q?style:=20=F0=9F=92=84=20format:=20make=20small?= =?UTF-8?q?=20assigned=20if=20else=20one-liners?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recurrent/tests/recurrence_rules_by_range.rs | 6 +----- lib/sched/task_handler.rs | 6 +----- lib/sched/utils/cron_date.rs | 12 ++---------- rustfmt.toml | 1 + 4 files changed, 5 insertions(+), 20 deletions(-) diff --git a/lib/sched/rules/recurrent/tests/recurrence_rules_by_range.rs b/lib/sched/rules/recurrent/tests/recurrence_rules_by_range.rs index 2a618a9..bb49840 100644 --- a/lib/sched/rules/recurrent/tests/recurrence_rules_by_range.rs +++ b/lib/sched/rules/recurrent/tests/recurrence_rules_by_range.rs @@ -14,11 +14,7 @@ fn between_10_and_20_seconds() { for i in 0..20 { let addend = if i < 11 { i } else { i - 10 - 1 }; - let minute = if i < 11 { - initial_minute - } else { - initial_minute + 1 - }; + let minute = if i < 11 { initial_minute } else { initial_minute + 1 }; next = rules.next_match_from(next).unwrap(); println!("[{i}]: {:?}", next); diff --git a/lib/sched/task_handler.rs b/lib/sched/task_handler.rs index febe303..d37ea7f 100644 --- a/lib/sched/task_handler.rs +++ b/lib/sched/task_handler.rs @@ -118,11 +118,7 @@ pub(crate) fn get_next_run_time( ) -> Option> { let mut next_run_so_far: Option> = None; - let base = if let Some(from) = from { - from - } else { - Local::now() - }; + let base = if let Some(from) = from { from } else { Local::now() }; for rule in rules { let rule_next_run = rule.next_from(base); diff --git a/lib/sched/utils/cron_date.rs b/lib/sched/utils/cron_date.rs index b30a598..bb2bb4f 100644 --- a/lib/sched/utils/cron_date.rs +++ b/lib/sched/utils/cron_date.rs @@ -181,11 +181,7 @@ impl LoolDate { pub fn set_nanos(&mut self, nanos: u32) { // avoid `whith_nanosecond` returning None for > 2_000_000_000 values // so we can safely unwrap the result - let nanos = if nanos > 2_000_000_000 { - 1_999_999_999 - } else { - nanos - }; + let nanos = if nanos > 2_000_000_000 { 1_999_999_999 } else { nanos }; self.date = self.date.with_nanosecond(nanos).unwrap(); } @@ -193,11 +189,7 @@ impl LoolDate { /// /// values greater than `2,000,000` will be clamped to `1,999,999` pub fn set_micros(&mut self, micros: u32) { - let micros = if micros > 2_000_000 { - 1_999_999 - } else { - micros - }; + let micros = if micros > 2_000_000 { 1_999_999 } else { micros }; self.date = self.date.with_nanosecond(micros * 1_000).unwrap(); } diff --git a/rustfmt.toml b/rustfmt.toml index f50e61a..de241c9 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -4,3 +4,4 @@ chain_width = 100 comment_width = 80 imports_indent = "Block" imports_granularity = "One" +single_line_if_else_max_width = 70 \ No newline at end of file