From ab43d61f2c61701c477f60bd936116ed46b72799 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 28 Sep 2022 14:20:14 +0200 Subject: [PATCH] Extract date value to avoid multi-line match scrutinee --- tests/dateutils.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/dateutils.rs b/tests/dateutils.rs index 8d0516dcda..1573d8c419 100644 --- a/tests/dateutils.rs +++ b/tests/dateutils.rs @@ -33,12 +33,9 @@ fn verify_against_date_command_local(path: &'static str, dt: NaiveDateTime) { // This is used while a decision is made wheter the `date` output needs to // be exactly matched, or whether LocalResult::Ambigious should be handled // differently - match Local.from_local_datetime( - &NaiveDate::from_ymd_opt(dt.year(), dt.month(), dt.day()) - .unwrap() - .and_hms_opt(dt.hour(), 5, 1) - .unwrap(), - ) { + + let date = NaiveDate::from_ymd_opt(dt.year(), dt.month(), dt.day()).unwrap(); + match Local.from_local_datetime(&date.and_hms_opt(dt.hour(), 5, 1).unwrap()) { chrono::LocalResult::Ambiguous(a, b) => assert!( format!("{}\n", a) == date_command_str || format!("{}\n", b) == date_command_str ),