Skip to content

Commit

Permalink
replace lazy_static with once_cell, drop direct dependency on serde
Browse files Browse the repository at this point in the history
  • Loading branch information
klensy committed Jun 1, 2021
1 parent c63cb01 commit 5afc594
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1743,9 +1743,8 @@ dependencies = [
"fs-err",
"getopts",
"jsonpath_lib",
"lazy_static",
"once_cell",
"regex",
"serde",
"serde_json",
"shlex",
]
Expand Down
3 changes: 1 addition & 2 deletions src/tools/jsondocck/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
12 changes: 6 additions & 6 deletions src/tools/jsondocck/src/main.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -94,19 +94,19 @@ impl fmt::Display for CommandKind {
}
}

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)
Expand Down

0 comments on commit 5afc594

Please sign in to comment.