diff --git a/Cargo.lock b/Cargo.lock index 0b277c0..41d7ecb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -760,10 +760,9 @@ dependencies = [ [[package]] name = "reqwew" -version = "0.3.1" +version = "0.4.0" dependencies = [ "bytes", - "once_cell", "reqwest", "serde", "serde_json", @@ -1043,18 +1042,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.69" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.69" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index ec3b0aa..149a198 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ license = "GPL-3.0" name = "reqwew" readme = "README.md" repository = "https://github.com/hack-ink/reqwew" -version = "0.3.1" +version = "0.4.0" [profile.ci-dev] incremental = false @@ -17,14 +17,14 @@ inherits = "dev" [dependencies] # crates.io -bytes = { version = "1.7" } -once_cell = { version = "1.19" } +bytes = { version = "1.8" } reqwest = { version = "0.12" } serde = { version = "1.0" } serde_json = { version = "1.0" } -thiserror = { version = "1.0" } -tokio = { version = "1.40" } +thiserror = { version = "2.0" } +tokio = { version = "1.41" } tracing = { version = "0.1" } [dev-dependencies] -tokio = { version = "1.40", features = ["macros"] } +# crates.io +tokio = { version = "1.41", features = ["macros"] } diff --git a/src/lib.rs b/src/lib.rs index b8b28a0..55b7b6f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,14 +7,12 @@ use error::*; #[cfg(test)] mod test; -pub use once_cell; pub use reqwest; // std -use std::{future::Future, time::Duration}; +use std::{future::Future, sync::LazyLock, time::Duration}; // crates.io use bytes::Bytes; -use once_cell::sync::Lazy; use reqwest::{Body, Client as RClient, IntoUrl, Method as RMethod}; use serde::de::DeserializeOwned; use tokio::time; @@ -380,10 +378,14 @@ impl Http for Client { /// /// # Example /// ```rust -/// use reqwew::{once_cell::sync::Lazy, Client}; +/// use reqwew::Client; +/// use std::sync::LazyLock; /// -/// pub static CLIENT: Lazy = reqwew::lazy(|| Client::default()); +/// pub static CLIENT: LazyLock = reqwew::lazy(|| Client::default()); /// ``` -pub const fn lazy(f: F) -> Lazy { - Lazy::new(f) +pub const fn lazy(f: F) -> LazyLock +where + F: FnOnce() -> Client, +{ + LazyLock::new(f) } diff --git a/src/test.rs b/src/test.rs index ca7bca8..a22cbed 100644 --- a/src/test.rs +++ b/src/test.rs @@ -3,7 +3,7 @@ use serde_json::Value; // self use super::*; -static CLIENT: Lazy = lazy(Default::default); +static CLIENT: LazyLock = lazy(Default::default); #[tokio::test] async fn http_and_response_should_work() {