Skip to content

Commit 10a76b6

Browse files
danieleadesdaniel.eades
authored and
daniel.eades
committed
remove use of 'lazy_static' (clippy::non_std_lazy_statics)
1 parent aacca46 commit 10a76b6

File tree

5 files changed

+6
-13
lines changed

5 files changed

+6
-13
lines changed

Cargo.lock

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

examples/web/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ crate-type = ["cdylib", "rlib"]
1010
[dependencies]
1111
graphql_client = { path = "../../graphql_client", features = ["reqwest"] }
1212
wasm-bindgen = "^0.2"
13-
lazy_static = "1.0.1"
1413
js-sys = "0.3.6"
1514
wasm-bindgen-futures = "0.4.18"
1615
reqwest = "0.12"

examples/web/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use graphql_client::{reqwest::post_graphql, GraphQLQuery};
2-
use lazy_static::lazy_static;
32
use std::cell::RefCell;
43
use std::sync::Mutex;
54
use wasm_bindgen::prelude::*;
@@ -18,9 +17,8 @@ fn log(s: &str) {
1817
web_sys::console::log_1(&JsValue::from_str(s));
1918
}
2019

21-
lazy_static! {
22-
static ref LAST_ENTRY: Mutex<RefCell<Option<String>>> = Mutex::new(RefCell::new(None));
23-
}
20+
static LAST_ENTRY: std::sync::LazyLock<Mutex<RefCell<Option<String>>>> =
21+
std::sync::LazyLock::new(|| Mutex::new(RefCell::new(None)));
2422

2523
async fn load_more() -> Result<JsValue, JsValue> {
2624
let url = "https://www.graphqlhub.com/graphql";

graphql_client_codegen/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ edition = "2018"
1111
graphql-introspection-query = { version = "0.2.0", path = "../graphql-introspection-query" }
1212
graphql-parser = "0.4"
1313
heck = ">=0.4, <=0.5"
14-
lazy_static = "1.3"
1514
proc-macro2 = { version = "^1.0", features = [] }
1615
quote = "^1.0"
1716
serde_json = "1.0"

graphql_client_codegen/src/lib.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
//! Crate for Rust code generation from a GraphQL query, schema, and options.
66
7-
use lazy_static::lazy_static;
87
use proc_macro2::TokenStream;
98
use quote::quote;
109
use schema::Schema;
@@ -45,10 +44,10 @@ type BoxError = Box<dyn std::error::Error + Send + Sync + 'static>;
4544
type CacheMap<T> = std::sync::Mutex<BTreeMap<std::path::PathBuf, T>>;
4645
type QueryDocument = graphql_parser::query::Document<'static, String>;
4746

48-
lazy_static! {
49-
static ref SCHEMA_CACHE: CacheMap<Schema> = CacheMap::default();
50-
static ref QUERY_CACHE: CacheMap<(String, QueryDocument)> = CacheMap::default();
51-
}
47+
static SCHEMA_CACHE: std::sync::LazyLock<CacheMap<Schema>> =
48+
std::sync::LazyLock::new(CacheMap::default);
49+
static QUERY_CACHE: std::sync::LazyLock<CacheMap<(String, QueryDocument)>> =
50+
std::sync::LazyLock::new(CacheMap::default);
5251

5352
fn get_set_cached<T: Clone>(
5453
cache: &CacheMap<T>,

0 commit comments

Comments
 (0)