style: 💄 format: make small assigned if else one-liners

This commit is contained in:
Lucas Colombo 2024-05-27 06:32:09 -03:00
parent 2f424ca9f9
commit f6b8fda19d
Signed by: lucas
GPG Key ID: EF34786CFEFFAE35
4 changed files with 5 additions and 20 deletions

View File

@ -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);

View File

@ -118,11 +118,7 @@ pub(crate) fn get_next_run_time(
) -> Option<DateTime<Local>> {
let mut next_run_so_far: Option<DateTime<Local>> = 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);

View File

@ -181,11 +181,7 @@ impl<Tz: TimeZone> LoolDate<Tz> {
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<Tz: TimeZone> LoolDate<Tz> {
///
/// 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();
}

View File

@ -4,3 +4,4 @@ chain_width = 100
comment_width = 80
imports_indent = "Block"
imports_granularity = "One"
single_line_if_else_max_width = 70