summaryrefslogtreecommitdiff
path: root/src/masks.rs
diff options
context:
space:
mode:
authorFredrik Meringdal <fmeringdal@hotmail.com>2020-10-16 23:17:49 +0200
committerFredrik Meringdal <fmeringdal@hotmail.com>2020-10-16 23:17:49 +0200
commite508161cd3580888febaef4bbb848e219797e378 (patch)
tree8c1640ea0dc261f39ae4b6bd9d2b8e2a4d43c41d /src/masks.rs
parent4bb8cfd0cda78574c1be2d7c137bfbf937bfe8cc (diff)
downloadrust_rrule-e508161cd3580888febaef4bbb848e219797e378.zip
clippy stuff fixed
Diffstat (limited to 'src/masks.rs')
-rw-r--r--src/masks.rs162
1 files changed, 81 insertions, 81 deletions
diff --git a/src/masks.rs b/src/masks.rs
index 2ae7941..59d4ee1 100644
--- a/src/masks.rs
+++ b/src/masks.rs
@@ -6,39 +6,39 @@ use once_cell::sync::Lazy;
// Every mask is 7 days longer to handle cross-year weekly periods.
-pub static MASKS: Lazy<Masks> = Lazy::new(|| Masks::new());
+pub static MASKS: Lazy<Masks> = Lazy::new(Masks::default);
#[derive(Clone)]
pub struct Masks {
- pub WDAY: Vec<usize>,
- pub M365: Vec<usize>,
- pub M365RANGE: Vec<usize>,
- pub M366: Vec<usize>,
- pub M366RANGE: Vec<usize>,
- pub MDAY365: Vec<usize>,
- pub MDAY366: Vec<usize>,
- pub NMDAY365: Vec<isize>,
- pub NMDAY366: Vec<isize>,
+ pub wday: Vec<usize>,
+ pub m365: Vec<usize>,
+ pub m365range: Vec<usize>,
+ pub m366: Vec<usize>,
+ pub m366range: Vec<usize>,
+ pub mday365: Vec<usize>,
+ pub mday366: Vec<usize>,
+ pub nmday365: Vec<isize>,
+ pub nmday366: Vec<isize>,
}
-impl Masks {
- pub fn new() -> Self {
- let M28: Vec<usize> = (1..29).collect();
- let M29: Vec<usize> = (1..30).collect();
- let M30: Vec<usize> = (1..31).collect();
- let M31: Vec<usize> = (1..32).collect();
+impl Default for Masks {
+ fn default() -> Self {
+ let m28: Vec<usize> = (1..29).collect();
+ let m29: Vec<usize> = (1..30).collect();
+ let m30: Vec<usize> = (1..31).collect();
+ let m31: Vec<usize> = (1..32).collect();
- let NM28: Vec<isize> = (-28..0).collect();
- let NM29: Vec<isize> = (-29..0).collect();
- let NM30: Vec<isize> = (-30..0).collect();
- let NM31: Vec<isize> = (-31..0).collect();
+ let nm28: Vec<isize> = (-28..0).collect();
+ let nm29: Vec<isize> = (-29..0).collect();
+ let nm30: Vec<isize> = (-30..0).collect();
+ let nm31: Vec<isize> = (-31..0).collect();
Self {
- WDAY: vec![(0..7).collect::<Vec<usize>>(); 55]
+ wday: vec![(0..7).collect::<Vec<usize>>(); 55]
.into_iter()
.flatten()
.collect(),
- M365: vec![
+ m365: vec![
vec![1; 31],
vec![2; 28],
vec![3; 31],
@@ -56,45 +56,45 @@ impl Masks {
.into_iter()
.flatten()
.collect(),
- M365RANGE: vec![0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365],
- MDAY366: vec![
- M31.clone(),
- M29.clone(),
- M31.clone(),
- M30.clone(),
- M31.clone(),
- M30.clone(),
- M31.clone(),
- M31.clone(),
- M30.clone(),
- M31.clone(),
- M30.clone(),
- M31.clone(),
- Vec::from(&M31.clone()[0..7]),
+ m365range: vec![0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365],
+ mday366: vec![
+ m31.clone(),
+ m29,
+ m31.clone(),
+ m30.clone(),
+ m31.clone(),
+ m30.clone(),
+ m31.clone(),
+ m31.clone(),
+ m30.clone(),
+ m31.clone(),
+ m30.clone(),
+ m31.clone(),
+ Vec::from(&m31[0..7]),
]
.into_iter()
.flatten()
.collect(),
- M366RANGE: vec![0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366],
- MDAY365: vec![
- M31.clone(),
- M28.clone(),
- M31.clone(),
- M30.clone(),
- M31.clone(),
- M30.clone(),
- M31.clone(),
- M31.clone(),
- M30.clone(),
- M31.clone(),
- M30.clone(),
- M31.clone(),
- Vec::from(&M31.clone()[0..7]),
+ m366range: vec![0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366],
+ mday365: vec![
+ m31.clone(),
+ m28,
+ m31.clone(),
+ m30.clone(),
+ m31.clone(),
+ m30.clone(),
+ m31.clone(),
+ m31.clone(),
+ m30.clone(),
+ m31.clone(),
+ m30,
+ m31.clone(),
+ Vec::from(&m31[0..7]),
]
.into_iter()
.flatten()
.collect(),
- M366: vec![
+ m366: vec![
vec![1; 31],
vec![2; 29],
vec![3; 31],
@@ -112,38 +112,38 @@ impl Masks {
.into_iter()
.flatten()
.collect(),
- NMDAY365: vec![
- NM31.clone(),
- NM28.clone(),
- NM31.clone(),
- NM30.clone(),
- NM31.clone(),
- NM30.clone(),
- NM31.clone(),
- NM31.clone(),
- NM30.clone(),
- NM31.clone(),
- NM30.clone(),
- NM31.clone(),
- Vec::from(&NM31.clone()[0..7]),
+ nmday365: vec![
+ nm31.clone(),
+ nm28,
+ nm31.clone(),
+ nm30.clone(),
+ nm31.clone(),
+ nm30.clone(),
+ nm31.clone(),
+ nm31.clone(),
+ nm30.clone(),
+ nm31.clone(),
+ nm30.clone(),
+ nm31.clone(),
+ Vec::from(&nm31[0..7]),
]
.into_iter()
.flatten()
.collect(),
- NMDAY366: vec![
- NM31.clone(),
- NM29.clone(),
- NM31.clone(),
- NM30.clone(),
- NM31.clone(),
- NM30.clone(),
- NM31.clone(),
- NM31.clone(),
- NM30.clone(),
- NM31.clone(),
- NM30.clone(),
- NM31.clone(),
- Vec::from(&NM31.clone()[0..7]),
+ nmday366: vec![
+ nm31.clone(),
+ nm29,
+ nm31.clone(),
+ nm30.clone(),
+ nm31.clone(),
+ nm30.clone(),
+ nm31.clone(),
+ nm31.clone(),
+ nm30.clone(),
+ nm31.clone(),
+ nm30,
+ nm31.clone(),
+ Vec::from(&nm31[0..7]),
]
.into_iter()
.flatten()