Debian Codegraph @

src/iter/yearinfo.rs

raw symbols SCIP
1 use superrust-analyzer cargo rrule 0.14.0 iter/::{
2 masksrust-analyzer cargo rrule 0.14.0 iter/masks/::MASKSrust-analyzer cargo rrule 0.14.0 iter/masks/MASKS.,
3 utilsrust-analyzer cargo rrule 0.14.0 iter/utils/::{days_since_unix_epochrust-analyzer cargo rrule 0.14.0 iter/utils/days_since_unix_epoch()., get_year_lenrust-analyzer cargo rrule 0.14.0 iter/utils/get_year_len()., pymodrust-analyzer cargo rrule 0.14.0 iter/utils/pymod().},
4 };
5 use craterust-analyzer cargo rrule 0.14.0 crate/::RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#;
6 use chronorust-analyzer cargo chrono 0.4.40 crate/::{Datelikerust-analyzer cargo chrono 0.4.40 traits/Datelike#, TimeZonerust-analyzer cargo chrono 0.4.40 offset/TimeZone#, Utcrust-analyzer cargo chrono 0.4.40 offset/utc/Utc#};
7
8 #[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:)]
9 pub(craterust-analyzer cargo rrule 0.14.0 crate/) struct BaseMasksrust-analyzer cargo rrule 0.14.0 iter/yearinfo/BaseMasks# {
10 month_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/BaseMasks#month_mask.: &'static [u8],
11 month_day_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/BaseMasks#month_day_mask.: &'static [i8],
12 neg_month_day_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/BaseMasks#neg_month_day_mask.: &'static [i8],
13 month_rangerust-analyzer cargo rrule 0.14.0 iter/yearinfo/BaseMasks#month_range.: &'static [u16],
14 weekday_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/BaseMasks#weekday_mask.: &'static [u32],
15 }
16
17 fn base_year_masksrust-analyzer cargo rrule 0.14.0 iter/yearinfo/base_year_masks().(year_weekday: u16, year_len: u16) -> BaseMasksrust-analyzer cargo rrule 0.14.0 iter/yearinfo/BaseMasks# {
18 if year_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().365 {
19 BaseMasksrust-analyzer cargo rrule 0.14.0 iter/yearinfo/BaseMasks# {
20 month_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/BaseMasks#month_mask.: &MASKSrust-analyzer cargo rrule 0.14.0 iter/masks/MASKS..month_365rust-analyzer cargo rrule 0.14.0 iter/masks/Masks#month_365.,
21 month_day_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/BaseMasks#month_day_mask.: &MASKSrust-analyzer cargo rrule 0.14.0 iter/masks/MASKS..month_day_365rust-analyzer cargo rrule 0.14.0 iter/masks/Masks#month_day_365.,
22 neg_month_day_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/BaseMasks#neg_month_day_mask.: &MASKSrust-analyzer cargo rrule 0.14.0 iter/masks/MASKS..neg_month_day_365rust-analyzer cargo rrule 0.14.0 iter/masks/Masks#neg_month_day_365.,
23 month_rangerust-analyzer cargo rrule 0.14.0 iter/yearinfo/BaseMasks#month_range.: &MASKSrust-analyzer cargo rrule 0.14.0 iter/masks/MASKS..month_365_rangerust-analyzer cargo rrule 0.14.0 iter/masks/Masks#month_365_range.,
24 weekday_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/BaseMasks#weekday_mask.: &MASKSrust-analyzer cargo rrule 0.14.0 iter/masks/MASKS..weekdayrust-analyzer cargo rrule 0.14.0 iter/masks/Masks#weekday.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u16>`]from().(year_weekday)..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().,
25 }
26 } else {
27 BaseMasksrust-analyzer cargo rrule 0.14.0 iter/yearinfo/BaseMasks# {
28 month_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/BaseMasks#month_mask.: &MASKSrust-analyzer cargo rrule 0.14.0 iter/masks/MASKS..month_366rust-analyzer cargo rrule 0.14.0 iter/masks/Masks#month_366.,
29 month_day_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/BaseMasks#month_day_mask.: &MASKSrust-analyzer cargo rrule 0.14.0 iter/masks/MASKS..month_day_366rust-analyzer cargo rrule 0.14.0 iter/masks/Masks#month_day_366.,
30 neg_month_day_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/BaseMasks#neg_month_day_mask.: &MASKSrust-analyzer cargo rrule 0.14.0 iter/masks/MASKS..neg_month_day_366rust-analyzer cargo rrule 0.14.0 iter/masks/Masks#neg_month_day_366.,
31 month_rangerust-analyzer cargo rrule 0.14.0 iter/yearinfo/BaseMasks#month_range.: &MASKSrust-analyzer cargo rrule 0.14.0 iter/masks/MASKS..month_366_rangerust-analyzer cargo rrule 0.14.0 iter/masks/Masks#month_366_range.,
32 weekday_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/BaseMasks#weekday_mask.: &MASKSrust-analyzer cargo rrule 0.14.0 iter/masks/MASKS..weekdayrust-analyzer cargo rrule 0.14.0 iter/masks/Masks#weekday.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u16>`]from().(year_weekday)..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().,
33 }
34 }
35 }
36
37 #[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:)]
38 pub(craterust-analyzer cargo rrule 0.14.0 crate/) struct YearInforust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo# {
39 /// The year
40 pub yearrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#year.: i32,
41 /// Number of days in the current year (365 or 366)
42 pub year_lenrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#year_len.: u16,
43 /// Number of days in the next year (365 or 366)
44 pub next_year_lenrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#next_year_len.: u16,
45 /// Number of days since Unix epoch
46 pub year_ordinalrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#year_ordinal.: i64,
47 pub month_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#month_mask.: &'static [u8],
48 pub month_day_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#month_day_mask.: &'static [i8],
49 pub neg_month_day_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#neg_month_day_mask.: &'static [i8],
50 pub month_rangerust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#month_range.: &'static [u16],
51 pub weekday_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#weekday_mask.: &'static [u32],
52 /// Week number mask
53 pub week_no_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#week_no_mask.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>>,
54 }
55
56 impl YearInforust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo# {
57 pub fn newrust-analyzer cargo rrule 0.14.0 iter/yearinfo/impl#[YearInfo]new().(year: i32, rrule: &RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#) -> Selfrust-analyzer cargo rrule 0.14.0 iter/yearinfo/impl#[YearInfo] {
58 // It should never fail, since there is always a 1st of January, is there?
59 let first_year_day = Utcrust-analyzer cargo chrono 0.4.40 offset/utc/Utc#.with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(year, 1, 1, 0, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().();
60
61 let year_len = get_year_lenrust-analyzer cargo rrule 0.14.0 iter/utils/get_year_len().(year);
62 let next_year_len = get_year_lenrust-analyzer cargo rrule 0.14.0 iter/utils/get_year_len().(year rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().1);
63 let year_ordinal = days_since_unix_epochrust-analyzer cargo rrule 0.14.0 iter/utils/days_since_unix_epoch().(&first_year_day);
64 let year_start_weekday = u16::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u16][`TryFrom<u32>`]try_from().(first_year_day.weekdayrust-analyzer cargo chrono 0.4.40 datetime/impl#[`DateTime<Tz>`][Datelike]weekday().().num_days_from_mondayrust-analyzer cargo chrono 0.4.40 weekday/impl#[Weekday]num_days_from_monday().())
65 .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 u16");
66
67 let base_masks = base_year_masksrust-analyzer cargo rrule 0.14.0 iter/yearinfo/base_year_masks().(year_start_weekday, year_len);
68
69 let mut result = Selfrust-analyzer cargo rrule 0.14.0 iter/yearinfo/impl#[YearInfo] {
70 yearrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#year.,
71 year_lenrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#year_len.,
72 next_year_lenrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#next_year_len.,
73 year_ordinalrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#year_ordinal.,
74 week_no_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#week_no_mask.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
75 month_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#month_mask.: base_masks.month_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/BaseMasks#month_mask.,
76 month_day_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#month_day_mask.: base_masks.month_day_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/BaseMasks#month_day_mask.,
77 neg_month_day_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#neg_month_day_mask.: base_masks.neg_month_day_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/BaseMasks#neg_month_day_mask.,
78 month_rangerust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#month_range.: base_masks.month_rangerust-analyzer cargo rrule 0.14.0 iter/yearinfo/BaseMasks#month_range.,
79 weekday_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#weekday_mask.: base_masks.weekday_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/BaseMasks#weekday_mask.,
80 };
81
82 if rrule.by_week_norust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_week_no..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
83 return result;
84 }
85
86 let mut week_no_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().(year_len) +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 7];
87
88 let rrule_week_start = u16::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u16][`TryFrom<u32>`]try_from().(rrule.week_startrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#week_start..num_days_from_mondayrust-analyzer cargo chrono 0.4.40 weekday/impl#[Weekday]num_days_from_monday().())
89 .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 u16");
90 let mut no1_week_start = pymodrust-analyzer cargo rrule 0.14.0 iter/utils/pymod().(7 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().year_start_weekday rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().rrule_week_start, 7);
91 let first_week_start = no1_week_start;
92 let year_len_ext = if no1_week_start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]ge().4 {
93 no1_week_start = 0;
94 // Number of days in the year, plus the days we got
95 // from last year.
96 let diff = i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<u16>`]from().(year_start_weekday) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<u16>`]from().(rrule_week_start);
97 result.year_lenrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#year_len.
98 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().u16::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u16][`TryFrom<i32>`]try_from().(pymodrust-analyzer cargo rrule 0.14.0 iter/utils/pymod().(diff, 7)).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("to be positive because 7 is the modulus")
99 } else {
100 // Number of days in the year, minus the days we
101 // left in last year.
102 year_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().no1_week_start
103 };
104
105 let div = year_len_ext rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Div<Self>`]div().7;
106 let year_mod = pymodrust-analyzer cargo rrule 0.14.0 iter/utils/pymod().(year_len_ext, 7);
107 let num_weeks = div rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().(year_mod rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Div<Self>`]div().4);
108
109 for &(mut n) in &rrule.by_week_norust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_week_no. {
110 let num_weeks =
111 i8::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i8][`TryFrom<u16>`]try_from().(num_weeks).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("num_weeks is 52-54 which is covered by i8::MAX");
112 if n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]lt().0 {
113 n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`AddAssign<Self>`]add_assign().num_weeks rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add().1;
114 }
115 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().(n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]gt().0 && n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]le().num_weeks) {
116 continue;
117 }
118
119 let i = if n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]gt().1 {
120 let n =
121 u16::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u16][`TryFrom<i8>`]try_from().(n).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("We know that 1 < n < i8::MAX which is covered by u16");
122 let mut i = no1_week_start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().((n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Mul<Self>`]mul().7);
123 if no1_week_start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]ne().first_week_start {
124 i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`SubAssign<Self>`]sub_assign().7 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().first_week_start;
125 }
126 i
127 } else {
128 no1_week_start
129 };
130
131 for j in i..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().7 {
132 let j = usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u16>`]from().(j);
133 week_no_mask[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().j]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut(). = 1;
134 if result.weekday_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#weekday_mask.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().j rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().rrule.week_startrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#week_start..num_days_from_mondayrust-analyzer cargo chrono 0.4.40 weekday/impl#[Weekday]num_days_from_monday().() {
135 break;
136 }
137 }
138 }
139
140 if rrule.by_week_norust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_week_no..containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&1) {
141 // Check week number 1 of next years as well
142 let mut i = no1_week_start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().num_weeks rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Mul<Self>`]mul().7;
143 if no1_week_start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]ne().first_week_start {
144 i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`SubAssign<Self>`]sub_assign().7 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().first_week_start;
145 }
146 if i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]lt().year_len {
147 // If week starts in next year, we
148 // don't care about it.
149 for j in i..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().7 {
150 let j = usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u16>`]from().(j);
151 week_no_mask[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().j]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut(). = 1;
152 if result.weekday_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#weekday_mask.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().j rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().rrule.week_startrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#week_start..num_days_from_mondayrust-analyzer cargo chrono 0.4.40 weekday/impl#[Weekday]num_days_from_monday().() {
153 break;
154 }
155 }
156 }
157 }
158
159 if no1_week_start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt().0 {
160 // Check last week number of last year as
161 // well. If no1_week_start is 0, either the year
162 // started on week start, or week number 1
163 // got days from last year, so there are no
164 // days from last year's last week number in
165 // this year.
166 let l_num_weeks = if rrule.by_week_norust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_week_no..containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][Neg]neg().1) {
167 -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][Neg]neg().1
168 } else {
169 let l_year_weekday = u16::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u16][`TryFrom<u32>`]try_from().(
170 Utcrust-analyzer cargo chrono 0.4.40 offset/utc/Utc#.with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(year rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().1, 1, 1, 0, 0, 0)
171 // It should never fail, since there is always a 1st of January, is there?
172 .unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().()
173 .weekdayrust-analyzer cargo chrono 0.4.40 datetime/impl#[`DateTime<Tz>`][Datelike]weekday().()
174 .num_days_from_mondayrust-analyzer cargo chrono 0.4.40 weekday/impl#[Weekday]num_days_from_monday().(),
175 )
176 .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 u16");
177
178 let rrule_week_start = u16::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u16][`TryFrom<u32>`]try_from().(rrule.week_startrust-analyzer cargo rrule 0.14.0 core/rrule/RRule#week_start..num_days_from_mondayrust-analyzer cargo chrono 0.4.40 weekday/impl#[Weekday]num_days_from_monday().())
179 .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 u16");
180 let ln_no1_week_start = pymodrust-analyzer cargo rrule 0.14.0 iter/utils/pymod().(7 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().l_year_weekday rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().rrule_week_start, 7);
181
182 let l_year_len = get_year_lenrust-analyzer cargo rrule 0.14.0 iter/utils/get_year_len().(year rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().1);
183 let week_start = if ln_no1_week_start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]ge().4 {
184 l_year_len
185 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().u16::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u16][`TryFrom<i32>`]try_from().(pymodrust-analyzer cargo rrule 0.14.0 iter/utils/pymod().(
186 i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<u16>`]from().(l_year_weekday) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<u16>`]from().(rrule_week_start),
187 7,
188 ))
189 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("7 is the modulo, so the range is 0-6, and u16 covers that range")
190 } else {
191 year_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().no1_week_start
192 };
193
194 52 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add().i8::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i8][`TryFrom<u16>`]try_from().(pymodrust-analyzer cargo rrule 0.14.0 iter/utils/pymod().(week_start, 7) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Div<Self>`]div().4)
195 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("7 is the modulo, so the range is 0-6, and i8 covers that range")
196 };
197
198 if rrule.by_week_norust-analyzer cargo rrule 0.14.0 core/rrule/RRule#by_week_no..containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&l_num_weeks) {
199 for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#no1_week_start {
200 let i = usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u16>`]from().(i);
201 week_no_mask[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().i]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut(). = 1;
202 }
203 }
204 }
205
206 result.week_no_maskrust-analyzer cargo rrule 0.14.0 iter/yearinfo/YearInfo#week_no_mask. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(week_no_mask);
207
208 result
209 }
210 }