Skip to content

Commit

Permalink
Remove lazy_static dependency (#149)
Browse files Browse the repository at this point in the history
Instead, we now use `lazy-regex`, which uses `once_cell` under
the hood, which might eventually become part of std.
  • Loading branch information
msrd0 authored Mar 12, 2024
1 parent 869c92b commit bfe457c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
3 changes: 1 addition & 2 deletions influxdb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ chrono = { version = "0.4.23", features = ["serde"], default-features = false }
futures-util = "0.3.17"
http = "0.2.4"
influxdb_derive = { version = "0.5.1", optional = true }
lazy_static = "1.4.0"
regex = "1.3.5"
lazy-regex = "3.1"
reqwest = { version = "0.11.4", default-features = false, optional = true }
surf = { version = "2.2.0", default-features = false, optional = true }
serde = { version = "1.0.186", optional = true }
Expand Down
15 changes: 6 additions & 9 deletions influxdb/src/query/line_proto_term.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
/// InfluxDB Line Protocol escaping helper module.
/// https://docs.influxdata.com/influxdb/v1.7/write_protocols/line_protocol_tutorial/
use crate::Type;
use lazy_static::lazy_static;
use regex::Regex;

lazy_static! {
pub static ref COMMAS_SPACES: Regex = Regex::new("[, ]").unwrap();
pub static ref COMMAS_SPACES_EQUALS: Regex = Regex::new("[, =]").unwrap();
pub static ref QUOTES_SLASHES: Regex = Regex::new(r#"["\\]"#).unwrap();
pub static ref SLASHES: Regex = Regex::new(r#"(\\|,| |=|")"#).unwrap();
}
use lazy_regex::{lazy_regex, Lazy, Regex};

pub static COMMAS_SPACES: Lazy<Regex> = lazy_regex!("[, ]");
pub static COMMAS_SPACES_EQUALS: Lazy<Regex> = lazy_regex!("[, =]");
pub static QUOTES_SLASHES: Lazy<Regex> = lazy_regex!(r#"["\\]"#);
pub static SLASHES: Lazy<Regex> = lazy_regex!(r#"(\\|,| |=|")"#);

pub enum LineProtoTerm<'a> {
Measurement(&'a str), // escape commas, spaces
Expand Down

0 comments on commit bfe457c

Please sign in to comment.