Debian Codegraph @

src/iter/monthinfo.rs

raw symbols SCIP
1 use superrust-analyzer cargo rrule 0.14.0 iter/::{utilsrust-analyzer cargo rrule 0.14.0 iter/utils/::pymodrust-analyzer cargo rrule 0.14.0 iter/utils/pymod()., yearinforust-analyzer cargo rrule 0.14.0 iter/yearinfo/::YearInforust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#};
2 use craterust-analyzer cargo rrule 0.14.0 crate/::{Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#, NWeekdayrust-analyzer cargo rrule 0.14.0 core/rrule/NWeekday#, RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#};
3
4 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
5 pub(craterust-analyzer cargo rrule 0.14.0 crate/) struct MonthInforust-analyzer cargo rrule 0.14.0 iter/monthinfo/MonthInfo# {
6 pub last_yearrust-analyzer cargo rrule 0.14.0 iter/monthinfo/MonthInfo#last_year.: i32,
7 pub last_monthrust-analyzer cargo rrule 0.14.0 iter/monthinfo/MonthInfo#last_month.: u8,
8 pub neg_weekday_maskrust-analyzer cargo rrule 0.14.0 iter/monthinfo/MonthInfo#neg_weekday_mask.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>,
9 }
10
11 impl MonthInforust-analyzer cargo rrule 0.14.0 iter/monthinfo/MonthInfo# {
12 pub fn newrust-analyzer cargo rrule 0.14.0 iter/monthinfo/impl#[MonthInfo]new().(year_info: &YearInforust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#, month: u8, rrule: &RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#) -> Selfrust-analyzer cargo rrule 0.14.0 iter/monthinfo/impl#[MonthInfo] {
13 let neg_weekday_mask = Selfrust-analyzer cargo rrule 0.14.0 iter/monthinfo/impl#[MonthInfo]::get_neg_weekday_maskrust-analyzer cargo rrule 0.14.0 iter/monthinfo/impl#[MonthInfo]get_neg_weekday_mask().(year_info, month, rrule);
14 Selfrust-analyzer cargo rrule 0.14.0 iter/monthinfo/impl#[MonthInfo] {
15 last_yearrust-analyzer cargo rrule 0.14.0 iter/monthinfo/MonthInfo#last_year.: year_info.yearrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#year.,
16 last_monthrust-analyzer cargo rrule 0.14.0 iter/monthinfo/MonthInfo#last_month.: month,
17 neg_weekday_maskrust-analyzer cargo rrule 0.14.0 iter/monthinfo/MonthInfo#neg_weekday_mask.,
18 }
19 }
20
21 fn get_neg_weekday_maskrust-analyzer cargo rrule 0.14.0 iter/monthinfo/impl#[MonthInfo]get_neg_weekday_mask().(year_info: &YearInforust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#, month: u8, rrule: &RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> {
22 let YearInforust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo# {
23 year_lenrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#year_len.,
24 month_rangerust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#month_range.,
25 weekday_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#weekday_mask.,
26 ..
27 } = year_info;
28
29 // Build up `ranges`
30 let mut ranges = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
31 if rrule.freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq. rust-analyzer cargo rrule 0.14.0 core/rrule/impl#[Frequency][`PartialEq<Self>`]eq().==rust-analyzer cargo rrule 0.14.0 core/rrule/impl#[Frequency][`PartialEq<Self>`]eq(). rust-analyzer cargo rrule 0.14.0 core/rrule/impl#[Frequency][`PartialEq<Self>`]eq().Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Yearlyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Yearly# {
32 if rrule.by_monthrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_month..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
33 ranges.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((0, u32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u32][`From<u16>`]from().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().year_len) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub().1));
34 } else {
35 for month in &rrule.by_monthrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_month. {
36 let month = usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u8>`]from().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().month);
37 let first = u32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u32][`From<u16>`]from().(month_range[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().month rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
38 let last = u32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u32][`From<u16>`]from().(month_range[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().month]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
39 ranges.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((first, last rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub().1));
40 }
41 }
42 } else if rrule.freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq. rust-analyzer cargo rrule 0.14.0 core/rrule/impl#[Frequency][`PartialEq<Self>`]eq().==rust-analyzer cargo rrule 0.14.0 core/rrule/impl#[Frequency][`PartialEq<Self>`]eq(). rust-analyzer cargo rrule 0.14.0 core/rrule/impl#[Frequency][`PartialEq<Self>`]eq().Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Monthlyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Monthly# {
43 let month = usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u8>`]from().(month);
44 let first = u32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u32][`From<u16>`]from().(month_range[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().month rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
45 let last = u32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u32][`From<u16>`]from().(month_range[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().month]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
46 ranges.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((first, last rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub().1));
47 }
48
49 if ranges.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
50 return vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
51 }
52
53 // Weekly frequency won't get here, so we may not
54 // care about cross-year weekly periods.
55 let mut neg_weekday_mask = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0; usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u16>`]from().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().year_len)];
56
57 // Loop over `ranges`
58 for (first, last) in ranges {
59 for by_weekday in &rrule.by_weekdayrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_weekday. {
60 // Only check Nth occurrences here
61 if let NWeekdayrust-analyzer cargo rrule 0.14.0 core/rrule/NWeekday#::Nthrust-analyzer cargo rrule 0.14.0 core/rrule/NWeekday#Nth#(number, weekday) = by_weekday {
62 let weekday = i16::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i16][`TryFrom<u32>`]try_from().(weekday.num_days_from_mondayrust-analyzer cargo chrono 0.4.40 weekday/impl#[Weekday]num_days_from_monday().())
63 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("num_days_from_monday is between 0 and 6 which is covered by i16");
64 let nth_weekday = if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().number rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().0 {
65 let number = match u32::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u32][`TryFrom<i16>`]try_from().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&i16`][Neg]neg().number) {
66 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(num) => num,
67 _ => continue,
68 };
69 let nth_last_week = match last.checked_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]checked_sub().((number rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub().1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().7) {
70 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(val) => val,
71 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => continue,
72 };
73 let index = match usize::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/ptr_try_from_impls/impl#[usize][`TryFrom<u32>`]try_from().(nth_last_week) {
74 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(i) => i,
75 _ => continue,
76 };
77 let nth_last_weekday = match weekday_mask.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(index) {
78 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(val) => i16::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i16][`TryFrom<u32>`]try_from().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().val).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("values in weekday mask are all between 0-6 which is covered by i32"),
79 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => continue,
80 };
81
82 // Adjust to get the correct weekday
83 let modulo = u32::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u32][`TryFrom<i16>`]try_from().(pymodrust-analyzer cargo rrule 0.14.0 iter/utils/pymod().(nth_last_weekday rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().weekday, 7))
84 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("pymod is positive because 7 is the modulus");
85 match nth_last_week.checked_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]checked_sub().(modulo) {
86 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(val) => val,
87 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => continue,
88 }
89 } else {
90 let number = match u32::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u32][`TryFrom<i16>`]try_from().(number rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&i16`][`Sub<i16>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&i16`][`Sub<i16>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&i16`][`Sub<i16>`]sub().1) {
91 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(num) => num,
92 _ => continue,
93 };
94 let nth_first_day = first rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().number rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().7;
95 let index = match usize::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/ptr_try_from_impls/impl#[usize][`TryFrom<u32>`]try_from().(nth_first_day) {
96 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(i) => i,
97 _ => continue,
98 };
99 let nth_first_day_weekday = match weekday_mask.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(index) {
100 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(val) => i16::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i16][`TryFrom<u32>`]try_from().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().val).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("values in weekday mask are all between 0-6 which is covered by i32"),
101 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => continue,
102 };
103
104 // Adjust to get the correct weekday
105 let a = u32::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u32][`TryFrom<i16>`]try_from().(7 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().nth_first_day_weekday rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().weekday)
106 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("to be positive because nth_first_day_weekday is at most 6");
107 nth_first_day rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().pymodrust-analyzer cargo rrule 0.14.0 iter/utils/pymod().(a, 7)
108 };
109 if first rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]le().nth_weekday && nth_weekday rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]le().last {
110 if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(nth_weekday) = usize::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/ptr_try_from_impls/impl#[usize][`TryFrom<u32>`]try_from().(nth_weekday) {
111 neg_weekday_mask[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().nth_weekday]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut(). = 1;
112 }
113 }
114 }
115 }
116 }
117
118 neg_weekday_mask
119 }
120 }
121
122 #[cfg(test)]
123 mod testsrust-analyzer cargo rrule 0.14.0 iter/monthinfo/tests/ {
124 use chronorust-analyzer cargo chrono 0.4.40 crate/::{TimeZonerust-analyzer cargo chrono 0.4.40 offset/TimeZone#, Weekdayrust-analyzer cargo chrono 0.4.40 weekday/Weekday#};
125
126 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#;
127
128 use superrust-analyzer cargo rrule 0.14.0 iter/monthinfo/::*;
129
130 const UTCrust-analyzer cargo rrule 0.14.0 iter/monthinfo/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.;
131
132 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
133 fn get_neg_weekday_mask_with_daily_freqrust-analyzer cargo rrule 0.14.0 iter/monthinfo/tests/get_neg_weekday_mask_with_daily_freq().() {
134 let rrule = RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# {
135 freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq.: Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Dailyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Daily#,
136 ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo rrule 0.14.0 core/rrule/impl#[`RRule<Unvalidated>`][Default]default().()
137 }
138 .validaterust-analyzer cargo rrule 0.14.0 core/rrule/impl#[`RRule<Unvalidated>`]validate().(UTCrust-analyzer cargo rrule 0.14.0 iter/monthinfo/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(1997, 1, 1, 0, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().())
139 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
140
141 let year_info = YearInforust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#::newrust-analyzer cargo rrule 0.14.0 iter/yearinfo/impl#[YearInfo]new().(1997, &rrule);
142
143 let neg_weekday_mask = MonthInforust-analyzer cargo rrule 0.14.0 iter/monthinfo/MonthInfo#::get_neg_weekday_maskrust-analyzer cargo rrule 0.14.0 iter/monthinfo/impl#[MonthInfo]get_neg_weekday_mask().(&year_info, 1, &rrule);
144 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(neg_weekday_mask.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
145 }
146
147 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
148 fn get_neg_weekday_mask_with_yearly_freqrust-analyzer cargo rrule 0.14.0 iter/monthinfo/tests/get_neg_weekday_mask_with_yearly_freq().() {
149 let rrule = RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# {
150 freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq.: Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Yearlyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Yearly#,
151 ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo rrule 0.14.0 core/rrule/impl#[`RRule<Unvalidated>`][Default]default().()
152 }
153 .validaterust-analyzer cargo rrule 0.14.0 core/rrule/impl#[`RRule<Unvalidated>`]validate().(UTCrust-analyzer cargo rrule 0.14.0 iter/monthinfo/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(1997, 1, 1, 0, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().())
154 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
155
156 let year_info = YearInforust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#::newrust-analyzer cargo rrule 0.14.0 iter/yearinfo/impl#[YearInfo]new().(1997, &rrule);
157
158 let neg_weekday_mask = MonthInforust-analyzer cargo rrule 0.14.0 iter/monthinfo/MonthInfo#::get_neg_weekday_maskrust-analyzer cargo rrule 0.14.0 iter/monthinfo/impl#[MonthInfo]get_neg_weekday_mask().(&year_info, 1, &rrule);
159 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(neg_weekday_mask.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), year_info.year_lenrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#year_len. as usize);
160 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(neg_weekday_mask.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#all().(|val| val == 0));
161 }
162
163 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
164 fn get_neg_weekday_mask_with_yearly_freq_and_byweekdayrust-analyzer cargo rrule 0.14.0 iter/monthinfo/tests/get_neg_weekday_mask_with_yearly_freq_and_byweekday().() {
165 let rrule = RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# {
166 freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq.: Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Yearlyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Yearly#,
167 by_weekdayrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_weekday.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
168 NWeekdayrust-analyzer cargo rrule 0.14.0 core/rrule/NWeekday#::newrust-analyzer cargo rrule 0.14.0 core/rrule/impl#[NWeekday]new().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Weekdayrust-analyzer cargo chrono 0.4.40 weekday/Weekday#::Monrust-analyzer cargo chrono 0.4.40 weekday/Weekday#Mon#),
169 NWeekdayrust-analyzer cargo rrule 0.14.0 core/rrule/NWeekday#::newrust-analyzer cargo rrule 0.14.0 core/rrule/impl#[NWeekday]new().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().2), Weekdayrust-analyzer cargo chrono 0.4.40 weekday/Weekday#::Thurust-analyzer cargo chrono 0.4.40 weekday/Weekday#Thu#),
170 NWeekdayrust-analyzer cargo rrule 0.14.0 core/rrule/NWeekday#::newrust-analyzer cargo rrule 0.14.0 core/rrule/impl#[NWeekday]new().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(1), Weekdayrust-analyzer cargo chrono 0.4.40 weekday/Weekday#::Thurust-analyzer cargo chrono 0.4.40 weekday/Weekday#Thu#),
171 ],
172 ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo rrule 0.14.0 core/rrule/impl#[`RRule<Unvalidated>`][Default]default().()
173 }
174 .validaterust-analyzer cargo rrule 0.14.0 core/rrule/impl#[`RRule<Unvalidated>`]validate().(UTCrust-analyzer cargo rrule 0.14.0 iter/monthinfo/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(1997, 1, 1, 0, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().())
175 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
176
177 let year_info = YearInforust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#::newrust-analyzer cargo rrule 0.14.0 iter/yearinfo/impl#[YearInfo]new().(1997, &rrule);
178
179 let neg_weekday_mask = MonthInforust-analyzer cargo rrule 0.14.0 iter/monthinfo/MonthInfo#::get_neg_weekday_maskrust-analyzer cargo rrule 0.14.0 iter/monthinfo/impl#[MonthInfo]get_neg_weekday_mask().(&year_info, 1, &rrule);
180 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(neg_weekday_mask.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), year_info.year_lenrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#year_len. as usize);
181 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(neg_weekday_mask
182 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
183 .enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().()
184 .allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#all().(|(idx, val)| match idx {
185 1 | 351 => val == 1,
186 _ => val == 0,
187 }));
188 }
189
190 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
191 fn get_neg_weekday_mask_with_monthly_freq_and_byweekdayrust-analyzer cargo rrule 0.14.0 iter/monthinfo/tests/get_neg_weekday_mask_with_monthly_freq_and_byweekday().() {
192 let rrule = RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule# {
193 freqrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#freq.: Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Monthlyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Monthly#,
194 by_weekdayrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_weekday.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
195 NWeekdayrust-analyzer cargo rrule 0.14.0 core/rrule/NWeekday#::newrust-analyzer cargo rrule 0.14.0 core/rrule/impl#[NWeekday]new().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Weekdayrust-analyzer cargo chrono 0.4.40 weekday/Weekday#::Monrust-analyzer cargo chrono 0.4.40 weekday/Weekday#Mon#),
196 NWeekdayrust-analyzer cargo rrule 0.14.0 core/rrule/NWeekday#::newrust-analyzer cargo rrule 0.14.0 core/rrule/impl#[NWeekday]new().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().2), Weekdayrust-analyzer cargo chrono 0.4.40 weekday/Weekday#::Thurust-analyzer cargo chrono 0.4.40 weekday/Weekday#Thu#),
197 NWeekdayrust-analyzer cargo rrule 0.14.0 core/rrule/NWeekday#::newrust-analyzer cargo rrule 0.14.0 core/rrule/impl#[NWeekday]new().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(1), Weekdayrust-analyzer cargo chrono 0.4.40 weekday/Weekday#::Thurust-analyzer cargo chrono 0.4.40 weekday/Weekday#Thu#),
198 ],
199 ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo rrule 0.14.0 core/rrule/impl#[`RRule<Unvalidated>`][Default]default().()
200 }
201 .validaterust-analyzer cargo rrule 0.14.0 core/rrule/impl#[`RRule<Unvalidated>`]validate().(UTCrust-analyzer cargo rrule 0.14.0 iter/monthinfo/tests/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(1997, 1, 1, 0, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().())
202 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
203
204 let year_info = YearInforust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#::newrust-analyzer cargo rrule 0.14.0 iter/yearinfo/impl#[YearInfo]new().(1997, &rrule);
205
206 let neg_weekday_mask = MonthInforust-analyzer cargo rrule 0.14.0 iter/monthinfo/MonthInfo#::get_neg_weekday_maskrust-analyzer cargo rrule 0.14.0 iter/monthinfo/impl#[MonthInfo]get_neg_weekday_mask().(&year_info, 1, &rrule);
207 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(neg_weekday_mask.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), year_info.year_lenrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#year_len. as usize);
208 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(neg_weekday_mask
209 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
210 .enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().()
211 .allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#all().(|(idx, val)| match idx {
212 1 | 22 => val == 1,
213 _ => val == 0,
214 }));
215 }
216 }