replace lazy_static with once_cell, drop direct dependency on serde

This commit is contained in:
klensy 2021-06-01 19:44:10 +03:00
parent c63cb014a0
commit 5afc594e62
3 changed files with 8 additions and 10 deletions

View File

@ -1743,9 +1743,8 @@ dependencies = [
"fs-err",
"getopts",
"jsonpath_lib",
"lazy_static",
"once_cell",
"regex",
"serde",
"serde_json",
"shlex",
]

View File

@ -8,8 +8,7 @@ edition = "2018"
jsonpath_lib = "0.2"
getopts = "0.2"
regex = "1.4"
lazy_static = "1.4"
shlex = "1.0"
serde = "1.0"
serde_json = "1.0"
fs-err = "2.5.0"
once_cell = "1.0"

View File

@ -1,5 +1,5 @@
use jsonpath_lib::select;
use lazy_static::lazy_static;
use once_cell::sync::Lazy;
use regex::{Regex, RegexBuilder};
use serde_json::Value;
use std::borrow::Cow;
@ -94,19 +94,19 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
}
lazy_static! {
static ref LINE_PATTERN: Regex = RegexBuilder::new(
static LINE_PATTERN: Lazy<Regex> = Lazy::new(|| {
RegexBuilder::new(
r#"
\s(?P<invalid>!?)@(?P<negated>!?)
(?P<cmd>[A-Za-z]+(?:-[A-Za-z]+)*)
(?P<args>.*)$
"#
"#,
)
.ignore_whitespace(true)
.unicode(true)
.build()
.unwrap();
}
.unwrap()
});
fn print_err(msg: &str, lineno: usize) {
eprintln!("Invalid command: {} on line {}", msg, lineno)