Skip to content

Commit d4480da

Browse files
chore: replace once_cell with std equivalents (LazyLock, OnceLock) (#4010)
1 parent a18f734 commit d4480da

File tree

8 files changed

+11
-18
lines changed

8 files changed

+11
-18
lines changed

Cargo.lock

Lines changed: 0 additions & 3 deletions
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
@@ -50,7 +50,6 @@ wasm-logger = "0.2"
5050
rand = "0.9"
5151
getrandom = { version = "0.3", features = ["wasm_js"] }
5252
instant = { version = "0.1", features = ["wasm-bindgen"] }
53-
once_cell = "1"
5453
rustversion = "1"
5554
strum = "0.27"
5655
strum_macros = "0.27"

examples/js_callback/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ wasm-bindgen.workspace = true
1010
yew = { path = "../../packages/yew", features = ["csr"] }
1111
wasm-bindgen-futures.workspace = true
1212
js-sys.workspace = true
13-
once_cell.workspace = true

examples/js_callback/src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
use once_cell::sync::OnceCell;
1+
use std::sync::OnceLock;
2+
23
use wasm_bindgen::prelude::*;
34
use wasm_bindgen::JsCast;
45
use wasm_bindgen_futures::JsFuture;
@@ -7,7 +8,7 @@ use yew::suspense::{use_future, SuspensionResult};
78

89
mod bindings;
910

10-
static WASM_BINDGEN_SNIPPETS_PATH: OnceCell<String> = OnceCell::new();
11+
static WASM_BINDGEN_SNIPPETS_PATH: OnceLock<String> = OnceLock::new();
1112

1213
#[function_component]
1314
fn Important() -> Html {

packages/yew-macro/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ proc-macro-error = "1"
2020
proc-macro2.workspace = true
2121
quote.workspace = true
2222
syn = { workspace = true, features = ["full", "extra-traits", "visit-mut"] }
23-
once_cell.workspace = true
2423
prettyplease = "0.2"
2524
rustversion.workspace = true
2625

packages/yew-macro/src/props/element.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::collections::HashSet;
2+
use std::sync::LazyLock;
23

3-
use once_cell::sync::Lazy;
44
use syn::parse::{Parse, ParseStream};
55

66
use super::{Prop, Props, SpecialProps};
@@ -48,7 +48,7 @@ impl Parse for ElementProps {
4848
}
4949
}
5050

51-
static BOOLEAN_SET: Lazy<HashSet<&'static str>> = Lazy::new(|| {
51+
static BOOLEAN_SET: LazyLock<HashSet<&'static str>> = LazyLock::new(|| {
5252
[
5353
// Living Standard
5454
// From: https://html.spec.whatwg.org/#attributes-3
@@ -85,7 +85,7 @@ static BOOLEAN_SET: Lazy<HashSet<&'static str>> = Lazy::new(|| {
8585
.into()
8686
});
8787

88-
static LISTENER_SET: Lazy<HashSet<&'static str>> = Lazy::new(|| {
88+
static LISTENER_SET: LazyLock<HashSet<&'static str>> = LazyLock::new(|| {
8989
[
9090
// Living Standard
9191
// From: https://html.spec.whatwg.org/multipage/webappapis.html#globaleventhandlers

tools/changelog/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@ serde = { workspace = true, features = ["derive"] }
1616
strum = { workspace = true, features = ["derive"] }
1717
clap = { workspace = true }
1818
semver = "1.0"
19-
once_cell.workspace = true

tools/changelog/src/create_log_line.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
use std::sync::Mutex;
1+
use std::sync::{LazyLock, Mutex};
22

33
use anyhow::{anyhow, Context, Result};
44
use git2::{Error, Oid, Repository};
5-
use once_cell::sync::Lazy;
65
use regex::Regex;
76

87
use crate::github_issue_labels_fetcher::GitHubIssueLabelsFetcher;
98
use crate::github_user_fetcher::GitHubUsersFetcher;
109
use crate::log_line::LogLine;
1110

12-
static REGEX_FOR_ISSUE_ID_CAPTURE: Lazy<Regex> =
13-
Lazy::new(|| Regex::new(r"\s*\(#(\d+)\)").unwrap());
14-
static GITHUB_ISSUE_LABELS_FETCHER: Lazy<Mutex<GitHubIssueLabelsFetcher>> =
15-
Lazy::new(Default::default);
11+
static REGEX_FOR_ISSUE_ID_CAPTURE: LazyLock<Regex> =
12+
LazyLock::new(|| Regex::new(r"\s*\(#(\d+)\)").unwrap());
13+
static GITHUB_ISSUE_LABELS_FETCHER: LazyLock<Mutex<GitHubIssueLabelsFetcher>> =
14+
LazyLock::new(Default::default);
1615

1716
pub fn create_log_line(
1817
repo: &Repository,

0 commit comments

Comments
 (0)