summaryrefslogtreecommitdiff
path: root/src/rrulestr.rs
diff options
context:
space:
mode:
authorFredrik Meringdal <fmeringdal@hotmail.com>2020-11-03 23:22:51 +0100
committerFredrik Meringdal <fmeringdal@hotmail.com>2020-11-03 23:22:51 +0100
commit00ba4141d5bb41f0ffc014c76bfdafcec7c02b6b (patch)
tree682f9f09ff13849a455d01ea7949a5c4a581663d /src/rrulestr.rs
parent66317f2566897556488af09e9ca73a06b9439b0f (diff)
downloadrust_rrule-00ba4141d5bb41f0ffc014c76bfdafcec7c02b6b.zip
using lazy_static instead of once_cell
Diffstat (limited to 'src/rrulestr.rs')
-rw-r--r--src/rrulestr.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/rrulestr.rs b/src/rrulestr.rs
index b798275..eb5a5be 100644
--- a/src/rrulestr.rs
+++ b/src/rrulestr.rs
@@ -5,22 +5,22 @@ use crate::rrule::RRule;
use crate::rruleset::RRuleSet;
use chrono::prelude::*;
use chrono_tz::{Tz, UTC};
-use once_cell::sync::Lazy;
use regex::Regex;
use std::str::FromStr;
-/// Some regex used for parsing the rrule string.
-static DATESTR_RE: Lazy<Regex> =
- Lazy::new(|| Regex::new(r"(?m)^(\d{4})(\d{2})(\d{2})(T(\d{2})(\d{2})(\d{2})Z?)?$").unwrap());
-static DTSTART_RE: Lazy<Regex> =
- Lazy::new(|| Regex::new(r"(?m)DTSTART(?:;TZID=([^:=]+?))?(?::|=)([^;\s]+)").unwrap());
-static RRULE_RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"(?m)^(?:RRULE|EXRULE):").unwrap());
-static PARSE_LINE_RE_1: Lazy<Regex> = Lazy::new(|| Regex::new(r"(?m)^\s+|\s+$").unwrap());
-static PARSE_LINE_RE_2: Lazy<Regex> = Lazy::new(|| Regex::new(r"(?m)^([A-Z]+?)[:;]").unwrap());
-static RDATE_RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"(?m)RDATE(?:;TZID=([^:=]+))?").unwrap());
-static EXDATE_RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"(?m)EXDATE(?:;TZID=([^:=]+))?").unwrap());
-static DATETIME_RE: Lazy<Regex> =
- Lazy::new(|| Regex::new(r"(?m)(VALUE=DATE(-TIME)?)|(TZID=)").unwrap());
+// Some regex used for parsing the rrule string.
+lazy_static! {
+ static ref DATESTR_RE: Regex =
+ Regex::new(r"(?m)^(\d{4})(\d{2})(\d{2})(T(\d{2})(\d{2})(\d{2})Z?)?$").unwrap();
+ static ref DTSTART_RE: Regex =
+ Regex::new(r"(?m)DTSTART(?:;TZID=([^:=]+?))?(?::|=)([^;\s]+)").unwrap();
+ static ref RRULE_RE: Regex = Regex::new(r"(?m)^(?:RRULE|EXRULE):").unwrap();
+ static ref PARSE_LINE_RE_1: Regex = Regex::new(r"(?m)^\s+|\s+$").unwrap();
+ static ref PARSE_LINE_RE_2: Regex = Regex::new(r"(?m)^([A-Z]+?)[:;]").unwrap();
+ static ref RDATE_RE: Regex = Regex::new(r"(?m)RDATE(?:;TZID=([^:=]+))?").unwrap();
+ static ref EXDATE_RE: Regex = Regex::new(r"(?m)EXDATE(?:;TZID=([^:=]+))?").unwrap();
+ static ref DATETIME_RE: Regex = Regex::new(r"(?m)(VALUE=DATE(-TIME)?)|(TZID=)").unwrap();
+}
fn parse_datestring_bit<T: FromStr>(
bits: &regex::Captures,