Fix clippy nags

This commit is contained in:
2023-11-05 13:28:20 +01:00
parent e458c69c80
commit fee9c7a171
4 changed files with 27 additions and 24 deletions

View File

@ -144,7 +144,7 @@ fn wind_speed_to_beaufort(mps: f64) -> BeaufortScale {
let index = beaufort_wind_speeds
.iter()
.enumerate()
.find_map(|(i, range)| range.contains(&mps).then(|| i))
.find_map(|(i, range)| range.contains(&mps).then_some(i))
.unwrap_or(beaufort_wind_speeds.len());
BeaufortScale(index as u8)

View File

@ -112,20 +112,19 @@ pub async fn lights_task(state: &State) {
};
if let Some(time) = time {
let handle = spawn(wake_task(
state.client_message.clone(),
cmd.clone(),
id.clone(),
day,
time,
));
let handle = spawn(wake_task(
state.client_message.clone(),
cmd.clone(),
id.clone(),
day,
time,
));
if let Some(old_handle) = wake_tasks.insert((id, day), handle) {
old_handle.abort();
}} else {
if let Some(old_handle) = wake_tasks.remove(&(id, day)) {
if let Some(old_handle) = wake_tasks.insert((id, day), handle) {
old_handle.abort();
}
} else if let Some(old_handle) = wake_tasks.remove(&(id, day)) {
old_handle.abort();
}
}
_ => {}
@ -181,7 +180,11 @@ fn next_alarm(now: DateTime<Local>, day: Weekday, time: NaiveTime) -> DateTime<L
let day_now = now.weekday().num_days_from_monday() as i64;
let alarm = now + chrono::Duration::days(day_of_alarm - day_now);
let mut alarm = alarm.date().and_time(time).unwrap();
let mut alarm = alarm
.date_naive()
.and_time(time)
.and_local_timezone(Local)
.unwrap();
if alarm <= now {
alarm += chrono::Duration::weeks(1);