Skip to content

Commit 25ee761

Browse files
committed
switch to LazyLock from std
1 parent 23014f3 commit 25ee761

File tree

6 files changed

+8
-12
lines changed

6 files changed

+8
-12
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ neli-wifi = { version = "0.6", features = ["async"] }
5757
nix = { version = "0.28", features = ["fs", "process"] }
5858
nom = "7.1.2"
5959
notmuch = { version = "0.8", optional = true }
60-
once_cell = "1"
6160
pipewire = { version = "0.8", default-features = false, optional = true }
6261
regex = "1.5"
6362
reqwest = { version = "0.11", features = ["json"] }

src/blocks/prelude.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub use std::borrow::Cow;
1717
pub use std::collections::HashMap;
1818
pub use std::fmt::Write;
1919
pub use std::pin::Pin;
20+
pub use std::sync::LazyLock as Lazy;
2021
pub use std::time::Duration;
2122

2223
pub use tokio::io::{AsyncBufRead, AsyncBufReadExt, AsyncReadExt, AsyncWriteExt};
@@ -25,8 +26,6 @@ pub use tokio::time::sleep;
2526

2627
pub use futures::{Stream, StreamExt};
2728

28-
pub use once_cell::sync::Lazy;
29-
3029
pub use smart_default::SmartDefault;
3130

3231
pub use async_trait::async_trait;

src/formatting/formatter/datetime.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
use chrono::format::{Fixed, Item, StrftimeItems};
22
use chrono::{DateTime, Datelike, Local, LocalResult, Locale, TimeZone, Timelike};
33
use chrono_tz::{OffsetName, Tz};
4-
use once_cell::sync::Lazy;
54

65
use std::fmt::Display;
6+
use std::sync::LazyLock;
77

88
use super::*;
99

1010
make_log_macro!(error, "datetime");
1111

1212
const DEFAULT_DATETIME_FORMAT: &str = "%a %d/%m %R";
1313

14-
pub static DEFAULT_DATETIME_FORMATTER: Lazy<DatetimeFormatter> =
15-
Lazy::new(|| DatetimeFormatter::new(Some(DEFAULT_DATETIME_FORMAT), None).unwrap());
14+
pub static DEFAULT_DATETIME_FORMATTER: LazyLock<DatetimeFormatter> =
15+
LazyLock::new(|| DatetimeFormatter::new(Some(DEFAULT_DATETIME_FORMAT), None).unwrap());
1616

1717
#[derive(Debug)]
1818
pub enum DatetimeFormatter {

src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ pub use tokio;
2828
use std::borrow::Cow;
2929
use std::future::Future;
3030
use std::pin::Pin;
31-
use std::sync::Arc;
31+
use std::sync::{Arc, LazyLock};
3232
use std::time::Duration;
3333

3434
use futures::stream::{FuturesUnordered, StreamExt};
3535
use futures::Stream;
36-
use once_cell::sync::Lazy;
3736
use tokio::process::Command;
3837
use tokio::sync::{mpsc, Notify};
3938

@@ -51,15 +50,15 @@ use crate::widget::{State, Widget};
5150
const APP_USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"),);
5251
const REQWEST_TIMEOUT: Duration = Duration::from_secs(10);
5352

54-
static REQWEST_CLIENT: Lazy<reqwest::Client> = Lazy::new(|| {
53+
static REQWEST_CLIENT: LazyLock<reqwest::Client> = LazyLock::new(|| {
5554
reqwest::Client::builder()
5655
.user_agent(APP_USER_AGENT)
5756
.timeout(REQWEST_TIMEOUT)
5857
.build()
5958
.unwrap()
6059
});
6160

62-
static REQWEST_CLIENT_IPV4: Lazy<reqwest::Client> = Lazy::new(|| {
61+
static REQWEST_CLIENT_IPV4: LazyLock<reqwest::Client> = LazyLock::new(|| {
6362
reqwest::Client::builder()
6463
.user_agent(APP_USER_AGENT)
6564
.local_address(Some(std::net::Ipv4Addr::UNSPECIFIED.into()))

src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ pub use map;
185185

186186
macro_rules! regex {
187187
($re:literal $(,)?) => {{
188-
static RE: once_cell::sync::OnceCell<regex::Regex> = once_cell::sync::OnceCell::new();
188+
static RE: std::sync::OnceLock<regex::Regex> = std::sync::OnceLock::new();
189189
RE.get_or_init(|| regex::Regex::new($re).unwrap())
190190
}};
191191
}

0 commit comments

Comments
 (0)