Skip to content

Commit 59fca19

Browse files
committed
refractor check_bounds
1 parent dcf4bb3 commit 59fca19

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/main.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -521,35 +521,33 @@ impl Config {
521521
fn check_bounds(start: &Option<Bound>, end: &Option<Bound>) -> Result<(), Error> {
522522
// current UTC date
523523
let current = Utc::now().date();
524-
match (&start, &end) {
524+
match start.as_ref().zip(end.as_ref()) {
525525
// start date is after end date
526-
(Some(Bound::Date(start)), Some(Bound::Date(end))) if end < start => {
526+
Some((Bound::Date(start), Bound::Date(end))) if end < &start => {
527527
bail!(
528528
"end should be after start, got start: {} and end {}",
529529
start,
530530
end
531531
);
532532
}
533533
// start date is after current date
534-
(Some(Bound::Date(start)), Some(Bound::Date(_end))) if start > &current => {
534+
Some((Bound::Date(start), _)) if start > &current => {
535535
bail!(
536536
"start date should be on or before current date, got start date request: {} and current date is {}",
537537
start,
538538
current
539539
);
540540
}
541541
// end date is after current date
542-
(Some(Bound::Date(_start)), Some(Bound::Date(end))) if end > &current => {
542+
Some((_, Bound::Date(end))) if end > &current => {
543543
bail!(
544544
"end date should be on or before current date, got start date request: {} and current date is {}",
545545
end,
546546
current
547547
);
548548
}
549-
_ => {}
549+
_ => Ok(())
550550
}
551-
552-
Ok(())
553551
}
554552

555553
// Application entry point

0 commit comments

Comments
 (0)