| 1 | use craterust-analyzer cargo rrule 0.14.0 crate/::RRuleResultrust-analyzer cargo rrule 0.14.0 core/rruleset/RRuleResult#; |
| 2 | use craterust-analyzer cargo rrule 0.14.0 crate/::{iterrust-analyzer cargo rrule 0.14.0 iter/::rrule_iterrust-analyzer cargo rrule 0.14.0 iter/rrule_iter/::WasLimitedrust-analyzer cargo rrule 0.14.0 iter/rrule_iter/WasLimited#, Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#}; |
| 3 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::{ |
| 4 | Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#::{Excludedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#Excluded#, Unboundedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#Unbounded#}, |
| 5 | RangeBoundsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeBounds#, |
| 6 | }; |
| 7 | |
| 8 | /// Helper function to collect dates given some filters. |
| 9 | /// |
| 10 | /// In the case where the iterator ended with errors, the error will be included, |
| 11 | /// otherwise the second value of the return tuple will be `None`. |
| 12 | pub(superrust-analyzer cargo rrule 0.14.0 core/) fn collect_with_errorrust-analyzer cargo rrule 0.14.0 core/utils/collect_with_error().<T>( |
| 13 | mut iterator: T, |
| 14 | start: &Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>>, |
| 15 | end: &Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>>, |
| 16 | inclusive: bool, |
| 17 | limit: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u16>, |
| 18 | ) -> RRuleResultrust-analyzer cargo rrule 0.14.0 core/rruleset/RRuleResult# |
| 19 | where |
| 20 | T: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>> + WasLimitedrust-analyzer cargo rrule 0.14.0 iter/rrule_iter/WasLimited#, |
| 21 | { |
| 22 | let mut list = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]; |
| 23 | let mut was_limited = false; |
| 24 | // This loop should always end because `.next()` has build in limits |
| 25 | // Once a limit is tripped it will break in the `None` case. |
| 26 | while limit.is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() || matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(limit, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(limit) if usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u16>`]from().(limit) >rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). list.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()) { |
| 27 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(value) = iterator.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#next().() { |
| 28 | if is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().(&value, start, end, inclusive) { |
| 29 | list.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(value); |
| 30 | } |
| 31 | if has_reached_the_endrust-analyzer cargo rrule 0.14.0 core/utils/has_reached_the_end().(&value, end, inclusive) { |
| 32 | // Date is after end date, so can stop iterating |
| 33 | break; |
| 34 | } |
| 35 | } else { |
| 36 | was_limited = iterator.was_limitedrust-analyzer cargo rrule 0.14.0 iter/rrule_iter/WasLimited#was_limited().(); |
| 37 | break; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | was_limited = was_limited || matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(limit, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(limit) if usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u16>`]from().(limit) == list.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()); |
| 42 | |
| 43 | RRuleResultrust-analyzer cargo rrule 0.14.0 core/rruleset/RRuleResult# { |
| 44 | datesrust-analyzer cargo rrule 0.14.0 core/rruleset/RRuleResult#dates.: list, |
| 45 | limitedrust-analyzer cargo rrule 0.14.0 core/rruleset/RRuleResult#limited.: was_limited, |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | /// Checks if `date` is after `end`. |
| 50 | fn has_reached_the_endrust-analyzer cargo rrule 0.14.0 core/utils/has_reached_the_end().( |
| 51 | date: &chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>, |
| 52 | end: &Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>>, |
| 53 | inclusive: bool, |
| 54 | ) -> bool { |
| 55 | if inclusive { |
| 56 | match end { |
| 57 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end) => !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().(..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeToInclusive#end).containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeToInclusive<Idx>`]contains().(&date), |
| 58 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => false, |
| 59 | } |
| 60 | } else { |
| 61 | match end { |
| 62 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end) => !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().(Unboundedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#Unbounded#, Excludedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#Excluded#(end)).containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeBounds#contains().(date), |
| 63 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => false, |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | /// Helper function to determine if a date is within a given range. |
| 69 | pub(superrust-analyzer cargo rrule 0.14.0 core/) fn is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 70 | date: &chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>, |
| 71 | start: &Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>>, |
| 72 | end: &Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>>, |
| 73 | inclusive: bool, |
| 74 | ) -> bool { |
| 75 | // Should it include or not include the start and/or end date? |
| 76 | if inclusive { |
| 77 | match (start, end) { |
| 78 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end)) => (start..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#end).containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]contains().(&date), |
| 79 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => (start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#).containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeFrom<Idx>`]contains().(&date), |
| 80 | (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end)) => (..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeToInclusive#end).containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeToInclusive<Idx>`]contains().(&date), |
| 81 | (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => true, |
| 82 | } |
| 83 | } else { |
| 84 | match (start, end) { |
| 85 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end)) => (Excludedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#Excluded#(start), Excludedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#Excluded#(end)).containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeBounds#contains().(date), |
| 86 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => (Excludedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#Excluded#(start), Unboundedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#Unbounded#).containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeBounds#contains().(date), |
| 87 | (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end)) => (Unboundedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#Unbounded#, Excludedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#Excluded#(end)).containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeBounds#contains().(date), |
| 88 | (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => true, |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | #[cfg(test)] |
| 94 | mod testsrust-analyzer cargo rrule 0.14.0 core/utils/tests/ { |
| 95 | use craterust-analyzer cargo rrule 0.14.0 crate/::corerust-analyzer cargo rrule 0.14.0 core/::Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#; |
| 96 | |
| 97 | use superrust-analyzer cargo rrule 0.14.0 core/utils/::*; |
| 98 | use chronorust-analyzer cargo chrono 0.4.40 crate/::TimeZonerust-analyzer cargo chrono 0.4.40 offset/TimeZone#; |
| 99 | |
| 100 | const UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC.: Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz# = Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#::UTCrust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]UTC.; |
| 101 | |
| 102 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 103 | fn in_range_exclusive_start_to_endrust-analyzer cargo rrule 0.14.0 core/utils/tests/in_range_exclusive_start_to_end().() { |
| 104 | let inclusive = false; |
| 105 | let start = UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 1, 8, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(); |
| 106 | let end = UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 1, 10, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(); |
| 107 | |
| 108 | // In middle |
| 109 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 110 | &UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 1, 9, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 111 | &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start), |
| 112 | &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end), |
| 113 | inclusive, |
| 114 | )); |
| 115 | // To small |
| 116 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 117 | &UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 1, 7, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 118 | &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start), |
| 119 | &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end), |
| 120 | inclusive, |
| 121 | )); |
| 122 | // To big |
| 123 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 124 | &UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 1, 11, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 125 | &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start), |
| 126 | &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end), |
| 127 | inclusive, |
| 128 | )); |
| 129 | // Equal to end |
| 130 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().(&end, &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start), &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end), inclusive)); |
| 131 | // Equal to start |
| 132 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().(&start, &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start), &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end), inclusive)); |
| 133 | } |
| 134 | |
| 135 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 136 | fn in_range_exclusive_startrust-analyzer cargo rrule 0.14.0 core/utils/tests/in_range_exclusive_start().() { |
| 137 | let inclusive = false; |
| 138 | let start = UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 1, 8, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(); |
| 139 | |
| 140 | // Just after |
| 141 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 142 | &UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 1, 9, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 143 | &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start), |
| 144 | &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 145 | inclusive, |
| 146 | )); |
| 147 | // To small |
| 148 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 149 | &UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 1, 7, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 150 | &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start), |
| 151 | &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 152 | inclusive, |
| 153 | )); |
| 154 | // Bigger |
| 155 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 156 | &UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 2, 8, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 157 | &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start), |
| 158 | &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 159 | inclusive, |
| 160 | )); |
| 161 | // Equal to start |
| 162 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().(&start, &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start), &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, inclusive)); |
| 163 | } |
| 164 | |
| 165 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 166 | fn in_range_exclusive_endrust-analyzer cargo rrule 0.14.0 core/utils/tests/in_range_exclusive_end().() { |
| 167 | let inclusive = false; |
| 168 | let end = UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 1, 10, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(); |
| 169 | |
| 170 | // Just before |
| 171 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 172 | &UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 1, 9, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 173 | &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 174 | &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end), |
| 175 | inclusive, |
| 176 | )); |
| 177 | // Smaller |
| 178 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 179 | &UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 9, 20, 10, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 180 | &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 181 | &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end), |
| 182 | inclusive, |
| 183 | )); |
| 184 | // Bigger |
| 185 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 186 | &UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 2, 8, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 187 | &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 188 | &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end), |
| 189 | inclusive, |
| 190 | )); |
| 191 | // Equal to end |
| 192 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().(&end, &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end), inclusive)); |
| 193 | } |
| 194 | |
| 195 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 196 | fn in_range_exclusive_allrust-analyzer cargo rrule 0.14.0 core/utils/tests/in_range_exclusive_all().() { |
| 197 | let inclusive = false; |
| 198 | |
| 199 | // Some date |
| 200 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 201 | &UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 1, 9, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 202 | &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 203 | &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 204 | inclusive, |
| 205 | )); |
| 206 | // Smaller |
| 207 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 208 | &UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 9, 20, 10, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 209 | &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 210 | &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 211 | inclusive, |
| 212 | )); |
| 213 | // Bigger |
| 214 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 215 | &UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 2, 8, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 216 | &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 217 | &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 218 | inclusive, |
| 219 | )); |
| 220 | } |
| 221 | |
| 222 | // ---------------- inclusive ----------------------- |
| 223 | |
| 224 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 225 | fn in_range_inclusive_start_to_endrust-analyzer cargo rrule 0.14.0 core/utils/tests/in_range_inclusive_start_to_end().() { |
| 226 | let inclusive = true; |
| 227 | let start = UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 1, 8, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(); |
| 228 | let end = UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 1, 10, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(); |
| 229 | |
| 230 | // In middle |
| 231 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 232 | &UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 1, 9, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 233 | &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start), |
| 234 | &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end), |
| 235 | inclusive, |
| 236 | )); |
| 237 | // To small |
| 238 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 239 | &UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 1, 7, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 240 | &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start), |
| 241 | &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end), |
| 242 | inclusive, |
| 243 | )); |
| 244 | // To big |
| 245 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 246 | &UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 1, 11, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 247 | &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start), |
| 248 | &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end), |
| 249 | inclusive, |
| 250 | )); |
| 251 | // Equal to end |
| 252 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().(&end, &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start), &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end), inclusive)); |
| 253 | // Equal to start |
| 254 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().(&start, &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start), &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end), inclusive)); |
| 255 | } |
| 256 | |
| 257 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 258 | fn in_range_inclusive_startrust-analyzer cargo rrule 0.14.0 core/utils/tests/in_range_inclusive_start().() { |
| 259 | let inclusive = true; |
| 260 | let start = UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 1, 8, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(); |
| 261 | |
| 262 | // Just after |
| 263 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 264 | &UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 1, 9, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 265 | &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start), |
| 266 | &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 267 | inclusive, |
| 268 | )); |
| 269 | // To small |
| 270 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 271 | &UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 1, 7, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 272 | &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start), |
| 273 | &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 274 | inclusive, |
| 275 | )); |
| 276 | // Bigger |
| 277 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 278 | &UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 2, 8, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 279 | &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start), |
| 280 | &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 281 | inclusive, |
| 282 | )); |
| 283 | // Equal to start |
| 284 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().(&start, &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start), &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, inclusive)); |
| 285 | } |
| 286 | |
| 287 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 288 | fn in_range_inclusive_endrust-analyzer cargo rrule 0.14.0 core/utils/tests/in_range_inclusive_end().() { |
| 289 | let inclusive = true; |
| 290 | let end = UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 1, 10, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(); |
| 291 | |
| 292 | // Just before |
| 293 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 294 | &UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 1, 9, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 295 | &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 296 | &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end), |
| 297 | inclusive, |
| 298 | )); |
| 299 | // Smaller |
| 300 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 301 | &UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 9, 20, 10, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 302 | &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 303 | &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end), |
| 304 | inclusive, |
| 305 | )); |
| 306 | // Bigger |
| 307 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 308 | &UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 2, 8, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 309 | &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 310 | &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end), |
| 311 | inclusive, |
| 312 | )); |
| 313 | // Equal to end |
| 314 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().(&end, &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, &Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end), inclusive)); |
| 315 | } |
| 316 | |
| 317 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 318 | fn in_range_inclusive_allrust-analyzer cargo rrule 0.14.0 core/utils/tests/in_range_inclusive_all().() { |
| 319 | let inclusive = true; |
| 320 | |
| 321 | // Some date |
| 322 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 323 | &UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 1, 9, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 324 | &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 325 | &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 326 | inclusive, |
| 327 | )); |
| 328 | // Smaller |
| 329 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 330 | &UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 9, 20, 10, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 331 | &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 332 | &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 333 | inclusive, |
| 334 | )); |
| 335 | // Bigger |
| 336 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_in_rangerust-analyzer cargo rrule 0.14.0 core/utils/is_in_range().( |
| 337 | &UTCrust-analyzer cargo rrule 0.14.0 core/utils/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 10, 2, 8, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 338 | &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 339 | &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 340 | inclusive, |
| 341 | )); |
| 342 | } |
| 343 | } |