Skip to content

Commit 5afc594

Browse files
committed
replace lazy_static with once_cell, drop direct dependency on serde
1 parent c63cb01 commit 5afc594

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

Cargo.lock

+1-2
Original file line numberDiff line numberDiff line change
@@ -1743,9 +1743,8 @@ dependencies = [
17431743
"fs-err",
17441744
"getopts",
17451745
"jsonpath_lib",
1746-
"lazy_static",
1746+
"once_cell",
17471747
"regex",
1748-
"serde",
17491748
"serde_json",
17501749
"shlex",
17511750
]

src/tools/jsondocck/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ edition = "2018"
88
jsonpath_lib = "0.2"
99
getopts = "0.2"
1010
regex = "1.4"
11-
lazy_static = "1.4"
1211
shlex = "1.0"
13-
serde = "1.0"
1412
serde_json = "1.0"
1513
fs-err = "2.5.0"
14+
once_cell = "1.0"

src/tools/jsondocck/src/main.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use jsonpath_lib::select;
2-
use lazy_static::lazy_static;
2+
use once_cell::sync::Lazy;
33
use regex::{Regex, RegexBuilder};
44
use serde_json::Value;
55
use std::borrow::Cow;
@@ -94,19 +94,19 @@ impl fmt::Display for CommandKind {
9494
}
9595
}
9696

97-
lazy_static! {
98-
static ref LINE_PATTERN: Regex = RegexBuilder::new(
97+
static LINE_PATTERN: Lazy<Regex> = Lazy::new(|| {
98+
RegexBuilder::new(
9999
r#"
100100
\s(?P<invalid>!?)@(?P<negated>!?)
101101
(?P<cmd>[A-Za-z]+(?:-[A-Za-z]+)*)
102102
(?P<args>.*)$
103-
"#
103+
"#,
104104
)
105105
.ignore_whitespace(true)
106106
.unicode(true)
107107
.build()
108-
.unwrap();
109-
}
108+
.unwrap()
109+
});
110110

111111
fn print_err(msg: &str, lineno: usize) {
112112
eprintln!("Invalid command: {} on line {}", msg, lineno)

0 commit comments

Comments
 (0)