@@ -769,16 +769,11 @@ pub fn try_merge_range_with_date_part(
769769 }
770770
771771 // Obtain the new range
772- let Some ( new_start_date) = NaiveDate :: from_ymd_opt ( year, value as u32 , 1 ) else {
773- return None ;
774- } ;
772+ let new_start_date = NaiveDate :: from_ymd_opt ( year, value as u32 , 1 ) ?;
775773
776- let Some ( new_end_date) = new_start_date
774+ let new_end_date = new_start_date
777775 . checked_add_months ( Months :: new ( 1 ) )
778- . and_then ( |date| date. checked_sub_days ( Days :: new ( 1 ) ) )
779- else {
780- return None ;
781- } ;
776+ . and_then ( |date| date. checked_sub_days ( Days :: new ( 1 ) ) ) ?;
782777
783778 // If the resulting range is outside of the original range, we can't merge
784779 // the filters
@@ -809,18 +804,12 @@ pub fn try_merge_range_with_date_part(
809804 let quarter_start_month = ( value - 1 ) * 3 + 1 ;
810805
811806 // Obtain the new range
812- let Some ( new_start_date) =
813- NaiveDate :: from_ymd_opt ( start_date_year, quarter_start_month as u32 , 1 )
814- else {
815- return None ;
816- } ;
807+ let new_start_date =
808+ NaiveDate :: from_ymd_opt ( start_date_year, quarter_start_month as u32 , 1 ) ?;
817809
818- let Some ( new_end_date) = new_start_date
810+ let new_end_date = new_start_date
819811 . checked_add_months ( Months :: new ( 3 ) )
820- . and_then ( |date| date. checked_sub_days ( Days :: new ( 1 ) ) )
821- else {
822- return None ;
823- } ;
812+ . and_then ( |date| date. checked_sub_days ( Days :: new ( 1 ) ) ) ?;
824813
825814 // Paranoid check, If the resulting range is outside of the original range, we can't merge
826815 // the filters
@@ -848,9 +837,7 @@ pub fn try_merge_range_with_date_part(
848837 let year = start_date. year ( ) ;
849838
850839 // Get January 4th of the year (which is always in week 1)
851- let Some ( jan_4) = NaiveDate :: from_ymd_opt ( year, 1 , 4 ) else {
852- return None ;
853- } ;
840+ let jan_4 = NaiveDate :: from_ymd_opt ( year, 1 , 4 ) ?;
854841
855842 // Get the Monday of week 1
856843 let iso_week = jan_4. iso_week ( ) ;
@@ -869,15 +856,9 @@ pub fn try_merge_range_with_date_part(
869856 let days_from_week_1 = ( value - 1 ) * 7 ;
870857 let week_1_monday = jan_4 - Days :: new ( jan_4. weekday ( ) . num_days_from_monday ( ) as u64 ) ;
871858
872- let Some ( week_start) =
873- week_1_monday. checked_add_days ( Days :: new ( days_from_week_1 as u64 ) )
874- else {
875- return None ;
876- } ;
859+ let week_start = week_1_monday. checked_add_days ( Days :: new ( days_from_week_1 as u64 ) ) ?;
877860
878- let Some ( week_end) = week_start. checked_add_days ( Days :: new ( 6 ) ) else {
879- return None ;
880- } ;
861+ let week_end = week_start. checked_add_days ( Days :: new ( 6 ) ) ?;
881862
882863 // Verify this week actually exists in this year (week 53 doesn't always exist)
883864 if week_start. iso_week ( ) . week ( ) != value as u32 {
0 commit comments