This commit is contained in:
Gregory Burd 2023-11-19 22:30:09 +00:00
parent d39f8aad4e
commit 290eb8e519
5 changed files with 11 additions and 11 deletions

View file

@ -128,7 +128,7 @@ peg::parser!(pub grammar parse() for str {
// result = r#""foo\\bar""#
// For the typical case, string_normal_chars will match multiple, leading to a single-element vec.
pub rule raw_text() -> String = "\"" t:((string_special_char() / string_normal_chars())*) "\""
{ t.join(&"") }
{ t.join("") }
pub rule text() -> SpannedValue
= v:raw_text() { SpannedValue::Text(v) }
@ -153,16 +153,16 @@ peg::parser!(pub grammar parse() for str {
"#instmicros" whitespace()+ d:$( digit()+ ) {
let micros = d.parse::<i64>().unwrap();
let seconds: i64 = micros / 1_000_000;
let nanos: u32 = ((micros % 1_000_000).abs() as u32) * 1000;
Utc.timestamp(seconds, nanos)
let nanos: u32 = ((micros % 1_000_000).unsigned_abs() as u32) * 1000;
Utc.timestamp_opt(seconds, nanos).unwrap()
}
rule inst_millis() -> DateTime<Utc> =
"#instmillis" whitespace()+ d:$( digit()+ ) {
let millis = d.parse::<i64>().unwrap();
let seconds: i64 = millis / 1000;
let nanos: u32 = ((millis % 1000).abs() as u32) * 1_000_000;
Utc.timestamp(seconds, nanos)
let nanos: u32 = ((millis % 1000).unsigned_abs() as u32) * 1_000_000;
Utc.timestamp_opt(seconds, nanos).unwrap()
}
rule inst() -> SpannedValue = t:(inst_millis() / inst_micros() / inst_string())

View file

@ -121,7 +121,7 @@ impl NamespaceableName {
if name.starts_with('_') {
Self::new(self.namespace(), &name[1..])
} else {
Self::new(self.namespace(), &format!("_{}", name))
Self::new(self.namespace(), format!("_{}", name))
}
}

View file

@ -1123,14 +1123,14 @@ impl OrJoin {
(self.clauses, self.unify_vars, vars)
}
pub fn mentioned_variables<'a>(&'a mut self) -> &'a BTreeSet<Variable> {
pub fn mentioned_variables(mut self) -> BTreeSet<Variable> {
if self.mentioned_vars.is_none() {
let m = self.collect_mentioned_variables();
self.mentioned_vars = Some(m);
}
if let Some(ref mentioned) = self.mentioned_vars {
mentioned
mentioned.clone()
} else {
unreachable!()
}

View file

@ -668,7 +668,7 @@ pub trait FromMicros {
impl FromMicros for DateTime<Utc> {
fn from_micros(ts: i64) -> Self {
Utc.timestamp(ts / 1_000_000, ((ts % 1_000_000).abs() as u32) * 1_000)
Utc.timestamp_opt(ts / 1_000_000, ((ts % 1_000_000).unsigned_abs() as u32) * 1_000).unwrap()
}
}
@ -690,7 +690,7 @@ pub trait FromMillis {
impl FromMillis for DateTime<Utc> {
fn from_millis(ts: i64) -> Self {
Utc.timestamp(ts / 1_000, ((ts % 1_000).abs() as u32) * 1_000)
Utc.timestamp_opt(ts / 1_000, ((ts % 1_000).abs() as u32) * 1_000).unwrap()
}
}

View file

@ -23,7 +23,7 @@ pub fn merge(left: &Value, right: &Value) -> Option<Value> {
match (left, right) {
(&Value::Map(ref l), &Value::Map(ref r)) => {
let mut result = l.clone();
result.extend(r.clone().into_iter());
result.extend(r.clone());
Some(Value::Map(result))
}
_ => None,