style: 💄 format: make small assigned if else one-liners
This commit is contained in:
parent
2f424ca9f9
commit
f6b8fda19d
@ -14,11 +14,7 @@ fn between_10_and_20_seconds() {
|
|||||||
|
|
||||||
for i in 0..20 {
|
for i in 0..20 {
|
||||||
let addend = if i < 11 { i } else { i - 10 - 1 };
|
let addend = if i < 11 { i } else { i - 10 - 1 };
|
||||||
let minute = if i < 11 {
|
let minute = if i < 11 { initial_minute } else { initial_minute + 1 };
|
||||||
initial_minute
|
|
||||||
} else {
|
|
||||||
initial_minute + 1
|
|
||||||
};
|
|
||||||
|
|
||||||
next = rules.next_match_from(next).unwrap();
|
next = rules.next_match_from(next).unwrap();
|
||||||
println!("[{i}]: {:?}", next);
|
println!("[{i}]: {:?}", next);
|
||||||
|
|||||||
@ -118,11 +118,7 @@ pub(crate) fn get_next_run_time(
|
|||||||
) -> Option<DateTime<Local>> {
|
) -> Option<DateTime<Local>> {
|
||||||
let mut next_run_so_far: Option<DateTime<Local>> = None;
|
let mut next_run_so_far: Option<DateTime<Local>> = None;
|
||||||
|
|
||||||
let base = if let Some(from) = from {
|
let base = if let Some(from) = from { from } else { Local::now() };
|
||||||
from
|
|
||||||
} else {
|
|
||||||
Local::now()
|
|
||||||
};
|
|
||||||
|
|
||||||
for rule in rules {
|
for rule in rules {
|
||||||
let rule_next_run = rule.next_from(base);
|
let rule_next_run = rule.next_from(base);
|
||||||
|
|||||||
@ -181,11 +181,7 @@ impl<Tz: TimeZone> LoolDate<Tz> {
|
|||||||
pub fn set_nanos(&mut self, nanos: u32) {
|
pub fn set_nanos(&mut self, nanos: u32) {
|
||||||
// avoid `whith_nanosecond` returning None for > 2_000_000_000 values
|
// avoid `whith_nanosecond` returning None for > 2_000_000_000 values
|
||||||
// so we can safely unwrap the result
|
// so we can safely unwrap the result
|
||||||
let nanos = if nanos > 2_000_000_000 {
|
let nanos = if nanos > 2_000_000_000 { 1_999_999_999 } else { nanos };
|
||||||
1_999_999_999
|
|
||||||
} else {
|
|
||||||
nanos
|
|
||||||
};
|
|
||||||
self.date = self.date.with_nanosecond(nanos).unwrap();
|
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`
|
/// values greater than `2,000,000` will be clamped to `1,999,999`
|
||||||
pub fn set_micros(&mut self, micros: u32) {
|
pub fn set_micros(&mut self, micros: u32) {
|
||||||
let micros = if micros > 2_000_000 {
|
let micros = if micros > 2_000_000 { 1_999_999 } else { micros };
|
||||||
1_999_999
|
|
||||||
} else {
|
|
||||||
micros
|
|
||||||
};
|
|
||||||
self.date = self.date.with_nanosecond(micros * 1_000).unwrap();
|
self.date = self.date.with_nanosecond(micros * 1_000).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,3 +4,4 @@ chain_width = 100
|
|||||||
comment_width = 80
|
comment_width = 80
|
||||||
imports_indent = "Block"
|
imports_indent = "Block"
|
||||||
imports_granularity = "One"
|
imports_granularity = "One"
|
||||||
|
single_line_if_else_max_width = 70
|
||||||
Loading…
x
Reference in New Issue
Block a user