summaryrefslogtreecommitdiff
path: root/src/iter/masks.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/iter/masks.rs')
-rw-r--r--src/iter/masks.rs57
1 files changed, 39 insertions, 18 deletions
diff --git a/src/iter/masks.rs b/src/iter/masks.rs
index 970c570..63ec771 100644
--- a/src/iter/masks.rs
+++ b/src/iter/masks.rs
@@ -4,8 +4,14 @@
// Every mask is 7 days longer to handle cross-year weekly periods.
-const WDAY: [[usize; 7]; 55] = [[0, 1, 2, 3, 4, 5, 6]; 55];
-const M365: [usize; 365 + 7] = [
+pub(crate) type WDAY_MASK = [usize; 7 * 55];
+pub(crate) type MASK_365 = [usize; 365 + 7];
+pub(crate) type MASK_366 = [usize; 366 + 7];
+pub(crate) type MASK_365_SIGNED = [isize; 365 + 7];
+pub(crate) type MASK_366_SIGNED = [isize; 366 + 7];
+pub(crate) type MONTH_RANGE_MASK = [usize; 13];
+
+const M365: MASK_365 = [
// 31
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
// 28
@@ -36,7 +42,7 @@ const M365: [usize; 365 + 7] = [
// 7 ------------------------------------------------------------------------------------------
1, 1, 1, 1, 1, 1, 1,
];
-const MDAY365: [usize; 365 + 7] = [
+const MDAY365: MASK_365_SIGNED = [
// 31
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31,
@@ -76,7 +82,7 @@ const MDAY365: [usize; 365 + 7] = [
// 7 -----------------------------------------------------------------------------------------
1, 2, 3, 4, 5, 6, 7,
];
-const NMDAY365: [isize; 365 + 7] = [
+const NMDAY365: MASK_365_SIGNED = [
// 31
-31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13,
-12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
@@ -116,9 +122,9 @@ const NMDAY365: [isize; 365 + 7] = [
// 7 -----------------------------------------------------------------------------------------
-31, -30, -29, -28, -27, -26, -25,
];
-const M365_RANGE: [usize; 13] = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365];
+const M365_RANGE: MONTH_RANGE_MASK = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365];
-const M366: [usize; 366 + 7] = [
+const M366: MASK_366 = [
// 31
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
// 29
@@ -149,7 +155,7 @@ const M366: [usize; 366 + 7] = [
// 7 ------------------------------------------------------------------------------------------
1, 1, 1, 1, 1, 1, 1,
];
-const MDAY366: [usize; 366 + 7] = [
+const MDAY366: MASK_366_SIGNED = [
// 31
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31,
@@ -189,8 +195,8 @@ const MDAY366: [usize; 366 + 7] = [
// 7 -----------------------------------------------------------------------------------------
1, 2, 3, 4, 5, 6, 7,
];
-const M366_RANGE: [usize; 13] = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366];
-const NMDAY366: [isize; 366 + 7] = [
+const M366_RANGE: MONTH_RANGE_MASK = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366];
+const NMDAY366: MASK_366_SIGNED = [
// 31
-31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13,
-12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
@@ -230,18 +236,33 @@ const NMDAY366: [isize; 366 + 7] = [
// 7 -----------------------------------------------------------------------------------------
-31, -30, -29, -28, -27, -26, -25,
];
+const WDAY: WDAY_MASK = [
+ 0, 1, 2, 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, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1,
+ 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5,
+ 6,
+];
#[derive(Clone)]
pub struct Masks {
- pub wday: [[usize; 7]; 55],
- pub m365: [usize; 365 + 7],
- pub m365range: [usize; 13],
- pub m366: [usize; 366 + 7],
- pub m366range: [usize; 13],
- pub mday365: [usize; 365 + 7],
- pub mday366: [usize; 366 + 7],
- pub nmday365: [isize; 365 + 7],
- pub nmday366: [isize; 366 + 7],
+ pub wday: WDAY_MASK,
+ pub m365: MASK_365,
+ pub m365range: MONTH_RANGE_MASK,
+ pub m366: MASK_366,
+ pub m366range: MONTH_RANGE_MASK,
+ pub mday365: MASK_365_SIGNED,
+ pub mday366: MASK_366_SIGNED,
+ pub nmday365: MASK_365_SIGNED,
+ pub nmday366: MASK_366_SIGNED,
}
pub const MASKS: Masks = Masks {