mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-22 00:51:11 -05:00
refactor: Move off of lazy_static
This commit is contained in:
parent
3bcd8a130e
commit
97f90da9bc
3 changed files with 18 additions and 12 deletions
8
Cargo.lock
generated
8
Cargo.lock
generated
|
@ -523,6 +523,12 @@ dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "once_cell"
|
||||||
|
version = "1.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "phf"
|
name = "phf"
|
||||||
version = "0.8.0"
|
version = "0.8.0"
|
||||||
|
@ -982,8 +988,8 @@ dependencies = [
|
||||||
"derive_more 0.99.11",
|
"derive_more 0.99.11",
|
||||||
"derive_setters",
|
"derive_setters",
|
||||||
"itertools",
|
"itertools",
|
||||||
"lazy_static",
|
|
||||||
"log",
|
"log",
|
||||||
|
"once_cell",
|
||||||
"regex",
|
"regex",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
|
|
@ -18,7 +18,7 @@ codecov = { repository = "crate-ci/typos" }
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
regex = "1.3"
|
regex = "1.3"
|
||||||
lazy_static = "1.2.0"
|
once_cell = "1.2.0"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
itertools = "0.9"
|
itertools = "0.9"
|
||||||
|
|
|
@ -138,21 +138,21 @@ impl Default for Parser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// `_`: number literal separator in Rust and other languages
|
||||||
|
// `'`: number literal separator in C++
|
||||||
|
static DIGITS: once_cell::sync::Lazy<regex::bytes::Regex> =
|
||||||
|
once_cell::sync::Lazy::new(|| regex::bytes::Regex::new(r#"^[0-9_']+$"#).unwrap());
|
||||||
|
|
||||||
fn is_number(ident: &[u8]) -> bool {
|
fn is_number(ident: &[u8]) -> bool {
|
||||||
lazy_static::lazy_static! {
|
|
||||||
// `_`: number literal separator in Rust and other languages
|
|
||||||
// `'`: number literal separator in C++
|
|
||||||
static ref DIGITS: regex::bytes::Regex = regex::bytes::Regex::new(r#"^[0-9_']+$"#).unwrap();
|
|
||||||
}
|
|
||||||
DIGITS.is_match(ident)
|
DIGITS.is_match(ident)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// `_`: number literal separator in Rust and other languages
|
||||||
|
// `'`: number literal separator in C++
|
||||||
|
static HEX: once_cell::sync::Lazy<regex::bytes::Regex> =
|
||||||
|
once_cell::sync::Lazy::new(|| regex::bytes::Regex::new(r#"^0[xX][0-9a-fA-F_']+$"#).unwrap());
|
||||||
|
|
||||||
fn is_hex(ident: &[u8]) -> bool {
|
fn is_hex(ident: &[u8]) -> bool {
|
||||||
lazy_static::lazy_static! {
|
|
||||||
// `_`: number literal separator in Rust and other languages
|
|
||||||
// `'`: number literal separator in C++
|
|
||||||
static ref HEX: regex::bytes::Regex = regex::bytes::Regex::new(r#"^0[xX][0-9a-fA-F_']+$"#).unwrap();
|
|
||||||
}
|
|
||||||
HEX.is_match(ident)
|
HEX.is_match(ident)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue