From 81b95b6388a9c47889aa6a1774256925299a69fe Mon Sep 17 00:00:00 2001 From: stackinspector Date: Thu, 22 Aug 2024 07:12:10 +0800 Subject: [PATCH 1/3] replace once_cell to std impl & bump MSRV --- Cargo.lock | 1 - Cargo.toml | 3 +-- src/agent.rs | 4 ++-- src/lib.rs | 4 ++-- src/tls/native_tls.rs | 5 ++--- src/tls/rustls.rs | 5 ++--- 6 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5b1f36f8..ef48ac88 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1004,7 +1004,6 @@ dependencies = [ "http", "log", "native-tls", - "once_cell", "rustls", "rustls-pemfile", "rustls-pki-types", diff --git a/Cargo.toml b/Cargo.toml index 6e70e7f0..79a60067 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ exclude = ["/cargo_deny.sh", "/deny.toml", "/test.sh"] # MSRV -rust-version = "1.67" +rust-version = "1.70" [package.metadata.docs.rs] features = ["rustls", "native-tls", "socks-proxy", "cookies", "gzip", "brotli", "charset", "json", "_test"] @@ -41,7 +41,6 @@ hoot = "0.2.1" http = "1.1.0" log = "0.4.22" thiserror = "1.0.61" -once_cell = "1.19.0" smallvec = "1.13.2" utf-8 = "0.7.6" diff --git a/src/agent.rs b/src/agent.rs index d3f2ccab..0678b773 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -216,8 +216,8 @@ impl Agent { #[cfg(any(feature = "gzip", feature = "brotli"))] { - use once_cell::sync::Lazy; - static ACCEPTS: Lazy = Lazy::new(|| { + use std::sync::LazyLock; + static ACCEPTS: LazyLock = LazyLock::new(|| { let mut value = String::with_capacity(10); #[cfg(feature = "gzip")] value.push_str("gzip"); diff --git a/src/lib.rs b/src/lib.rs index 5a755cc4..c66401d9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -398,12 +398,12 @@ mk_method!(trace, TRACE, WithoutBody); #[cfg(test)] pub(crate) mod test { - use once_cell::sync::Lazy; + use std::sync::LazyLock; use super::*; pub fn init_test_log() { - static INIT_LOG: Lazy<()> = Lazy::new(env_logger::init); + static INIT_LOG: LazyLock<()> = LazyLock::new(env_logger::init); *INIT_LOG } diff --git a/src/tls/native_tls.rs b/src/tls/native_tls.rs index 0300029d..d8bf9e92 100644 --- a/src/tls/native_tls.rs +++ b/src/tls/native_tls.rs @@ -1,7 +1,7 @@ use std::convert::TryFrom; use std::fmt; use std::io::{Read, Write}; -use std::sync::Arc; +use std::sync::{Arc, OnceLock}; use crate::tls::{RootCerts, TlsProvider}; use crate::transport::time::NextTimeout; @@ -10,7 +10,6 @@ use der::pem::LineEnding; use der::Document; use native_tls::{Certificate, HandshakeError, Identity, TlsConnector}; use native_tls::{TlsConnectorBuilder, TlsStream}; -use once_cell::sync::OnceCell; use super::TlsConfig; @@ -19,7 +18,7 @@ use super::TlsConfig; /// Requires feature flag **native-tls**. #[derive(Default)] pub struct NativeTlsConnector { - connector: OnceCell>, + connector: OnceLock>, } impl Connector for NativeTlsConnector { diff --git a/src/tls/rustls.rs b/src/tls/rustls.rs index 8dfe1f99..8bd128f9 100644 --- a/src/tls/rustls.rs +++ b/src/tls/rustls.rs @@ -1,9 +1,8 @@ use std::convert::TryInto; use std::fmt; use std::io::{Read, Write}; -use std::sync::Arc; +use std::sync::{Arc, OnceLock}; -use once_cell::sync::OnceCell; use rustls::client::danger::{HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier}; use rustls::{ClientConfig, ClientConnection, RootCertStore, StreamOwned, ALL_VERSIONS}; use rustls_pki_types::{CertificateDer, PrivateKeyDer, PrivatePkcs1KeyDer, PrivatePkcs8KeyDer}; @@ -23,7 +22,7 @@ use super::TlsConfig; /// Requires feature flag **rustls**. #[derive(Default)] pub struct RustlsConnector { - config: OnceCell>, + config: OnceLock>, } impl Connector for RustlsConnector { From 642aaf46415ae1770fe0e75bd81b18a7b1738405 Mon Sep 17 00:00:00 2001 From: stackinspector Date: Thu, 22 Aug 2024 07:16:26 +0800 Subject: [PATCH 2/3] bump rust edition to 2021 --- Cargo.toml | 2 +- src/agent.rs | 1 - src/cookies.rs | 2 -- src/lib.rs | 2 -- src/proxy.rs | 1 - src/request.rs | 1 - src/tls/native_tls.rs | 1 - src/tls/rustls.rs | 1 - src/util.rs | 1 - 9 files changed, 1 insertion(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 79a60067..4617bf9b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ repository = "https://github.com/algesten/ureq" readme = "README.md" keywords = ["web", "request", "https", "http", "client"] categories = ["web-programming::http-client"] -edition = "2018" +edition = "2021" exclude = ["/cargo_deny.sh", "/deny.toml", "/test.sh"] diff --git a/src/agent.rs b/src/agent.rs index 0678b773..4eea07b0 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -1,4 +1,3 @@ -use std::convert::TryFrom; use std::fmt::Debug; use std::sync::Arc; diff --git a/src/cookies.rs b/src/cookies.rs index 07cc5e9b..4aab24c6 100644 --- a/src/cookies.rs +++ b/src/cookies.rs @@ -267,8 +267,6 @@ impl fmt::Display for Cookie<'_> { #[cfg(test)] mod test { - use std::convert::TryFrom; - use super::*; fn uri() -> Uri { diff --git a/src/lib.rs b/src/lib.rs index c66401d9..788e8eb8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -317,8 +317,6 @@ #[macro_use] extern crate log; -use std::convert::TryFrom; - /// Re-exported http-crate. pub use http; diff --git a/src/proxy.rs b/src/proxy.rs index cdcc49d9..9a077af7 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -1,7 +1,6 @@ use base64::prelude::BASE64_STANDARD; use base64::Engine; use hoot::parser::try_parse_response; -use std::convert::{TryFrom, TryInto}; use std::fmt; use std::io::Write; diff --git a/src/request.rs b/src/request.rs index ee18f0cb..113cfc6a 100644 --- a/src/request.rs +++ b/src/request.rs @@ -1,4 +1,3 @@ -use std::convert::TryFrom; use std::fmt; use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; diff --git a/src/tls/native_tls.rs b/src/tls/native_tls.rs index d8bf9e92..85d15f7b 100644 --- a/src/tls/native_tls.rs +++ b/src/tls/native_tls.rs @@ -1,4 +1,3 @@ -use std::convert::TryFrom; use std::fmt; use std::io::{Read, Write}; use std::sync::{Arc, OnceLock}; diff --git a/src/tls/rustls.rs b/src/tls/rustls.rs index 8bd128f9..f8e92297 100644 --- a/src/tls/rustls.rs +++ b/src/tls/rustls.rs @@ -1,4 +1,3 @@ -use std::convert::TryInto; use std::fmt; use std::io::{Read, Write}; use std::sync::{Arc, OnceLock}; diff --git a/src/util.rs b/src/util.rs index c28b26fa..5c2c2337 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,5 +1,4 @@ use core::fmt; -use std::convert::TryFrom; use std::io::{self, ErrorKind}; use http::uri::{Authority, Scheme}; From 48f95d0814e97494221cd13ece0085d08397cacd Mon Sep 17 00:00:00 2001 From: stackinspector Date: Thu, 22 Aug 2024 07:23:00 +0800 Subject: [PATCH 3/3] fix: feature `lazy_cell` requires 1.80 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 4617bf9b..eaa03f7d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ exclude = ["/cargo_deny.sh", "/deny.toml", "/test.sh"] # MSRV -rust-version = "1.70" +rust-version = "1.80" [package.metadata.docs.rs] features = ["rustls", "native-tls", "socks-proxy", "cookies", "gzip", "brotli", "charset", "json", "_test"]