Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace once_cell to std impl #790

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ 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"]


# MSRV
rust-version = "1.67"
rust-version = "1.80"

[package.metadata.docs.rs]
features = ["rustls", "native-tls", "socks-proxy", "cookies", "gzip", "brotli", "charset", "json", "_test"]
Expand Down Expand Up @@ -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"

Expand Down
5 changes: 2 additions & 3 deletions src/agent.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::convert::TryFrom;
use std::fmt::Debug;
use std::sync::Arc;

Expand Down Expand Up @@ -216,8 +215,8 @@ impl Agent {

#[cfg(any(feature = "gzip", feature = "brotli"))]
{
use once_cell::sync::Lazy;
static ACCEPTS: Lazy<String> = Lazy::new(|| {
use std::sync::LazyLock;
static ACCEPTS: LazyLock<String> = LazyLock::new(|| {
let mut value = String::with_capacity(10);
#[cfg(feature = "gzip")]
value.push_str("gzip");
Expand Down
2 changes: 0 additions & 2 deletions src/cookies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,6 @@ impl fmt::Display for Cookie<'_> {
#[cfg(test)]
mod test {

use std::convert::TryFrom;

use super::*;

fn uri() -> Uri {
Expand Down
6 changes: 2 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,6 @@
#[macro_use]
extern crate log;

use std::convert::TryFrom;

/// Re-exported http-crate.
pub use http;

Expand Down Expand Up @@ -398,12 +396,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
}

Expand Down
1 change: 0 additions & 1 deletion src/proxy.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
1 change: 0 additions & 1 deletion src/request.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::convert::TryFrom;
use std::fmt;
use std::marker::PhantomData;
use std::ops::{Deref, DerefMut};
Expand Down
6 changes: 2 additions & 4 deletions src/tls/native_tls.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
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;
Expand All @@ -10,7 +9,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;

Expand All @@ -19,7 +17,7 @@ use super::TlsConfig;
/// Requires feature flag **native-tls**.
#[derive(Default)]
pub struct NativeTlsConnector {
connector: OnceCell<Arc<TlsConnector>>,
connector: OnceLock<Arc<TlsConnector>>,
}

impl Connector for NativeTlsConnector {
Expand Down
6 changes: 2 additions & 4 deletions src/tls/rustls.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
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};
Expand All @@ -23,7 +21,7 @@ use super::TlsConfig;
/// Requires feature flag **rustls**.
#[derive(Default)]
pub struct RustlsConnector {
config: OnceCell<Arc<ClientConfig>>,
config: OnceLock<Arc<ClientConfig>>,
}

impl Connector for RustlsConnector {
Expand Down
1 change: 0 additions & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use core::fmt;
use std::convert::TryFrom;
use std::io::{self, ErrorKind};

use http::uri::{Authority, Scheme};
Expand Down