From ad1cb9f03b5ea3d37fbf87e459cb221314e9480c Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Mon, 10 Feb 2025 13:32:31 +0100 Subject: [PATCH] Remove the dependency on `lazy_static` in favour of buildt-in `LazyLock` (#755) --- Cargo.lock | 1 - espflash/Cargo.toml | 2 -- espflash/src/cli/monitor/parser/mod.rs | 13 +++++-------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8d145b8b..61846e14 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1268,7 +1268,6 @@ dependencies = [ "flate2", "hex", "indicatif", - "lazy_static", "libc", "log", "md-5", diff --git a/espflash/Cargo.toml b/espflash/Cargo.toml index 530e02bf..1523cf31 100644 --- a/espflash/Cargo.toml +++ b/espflash/Cargo.toml @@ -40,7 +40,6 @@ esp-idf-part = "0.5.0" flate2 = "1.0.35" hex = { version = "0.4.3", features = ["serde"] } indicatif = { version = "0.17.9", optional = true } -lazy_static = { version = "1.5.0", optional = true } log = "0.4.22" md-5 = "0.10.6" miette = "7.4.0" @@ -74,7 +73,6 @@ cli = [ "dep:directories", "dep:env_logger", "dep:indicatif", - "dep:lazy_static", "dep:parse_int", "dep:toml", "dep:update-informer", diff --git a/espflash/src/cli/monitor/parser/mod.rs b/espflash/src/cli/monitor/parser/mod.rs index a58551d1..a9266400 100644 --- a/espflash/src/cli/monitor/parser/mod.rs +++ b/espflash/src/cli/monitor/parser/mod.rs @@ -1,25 +1,22 @@ -pub mod esp_defmt; -pub mod serial; - -use std::{borrow::Cow, io::Write}; +use std::{borrow::Cow, io::Write, sync::LazyLock}; use crossterm::{ style::{Color, Print, PrintStyledContent, Stylize}, QueueableCommand, }; -use lazy_static::lazy_static; use regex::Regex; use crate::cli::monitor::{line_endings::normalized, symbols::Symbols}; +pub mod esp_defmt; +pub mod serial; + pub trait InputParser { fn feed(&mut self, bytes: &[u8], out: &mut dyn Write); } // Pattern to much a function address in serial output. -lazy_static! { - static ref RE_FN_ADDR: Regex = Regex::new(r"0x[[:xdigit:]]{8}").unwrap(); -} +static RE_FN_ADDR: LazyLock = LazyLock::new(|| Regex::new(r"0x[[:xdigit:]]{8}").unwrap()); fn resolve_addresses( symbols: &Symbols<'_>,