Replace lazy_static! with once_cell Lazy (#176)

Modern rust code bases prefer once_cell::sync::Lazy over the older
macro based lazy_static.
This commit is contained in:
Martin Algesten
2020-10-04 18:35:31 +02:00
committed by GitHub
parent b58a3a53b0
commit 0bf981031b
3 changed files with 10 additions and 14 deletions

View File

@@ -327,16 +327,14 @@ fn configure_certs(config: &mut rustls::ClientConfig) {
#[cfg(all(feature = "tls", not(feature = "native-tls")))]
pub(crate) fn connect_https(unit: &Unit, hostname: &str) -> Result<Stream, Error> {
use lazy_static::lazy_static;
use once_cell::sync::Lazy;
use std::sync::Arc;
lazy_static! {
static ref TLS_CONF: Arc<rustls::ClientConfig> = {
let mut config = rustls::ClientConfig::new();
configure_certs(&mut config);
Arc::new(config)
};
}
static TLS_CONF: Lazy<Arc<rustls::ClientConfig>> = Lazy::new(|| {
let mut config = rustls::ClientConfig::new();
configure_certs(&mut config);
Arc::new(config)
});
let port = unit.url.port().unwrap_or(443);