Replace once_cell with LazyLock

This commit is contained in:
Matt Brubeck 2024-09-16 08:49:21 -07:00
parent de24f1dd44
commit 04e4eae1e3
3 changed files with 3 additions and 6 deletions

1
Cargo.lock generated
View file

@ -28,7 +28,6 @@ dependencies = [
"glob", "glob",
"log", "log",
"mime_guess", "mime_guess",
"once_cell",
"percent-encoding", "percent-encoding",
"rcgen", "rcgen",
"tokio", "tokio",

View file

@ -19,7 +19,6 @@ getopts = "0.2.21"
glob = "0.3" glob = "0.3"
log = "0.4" log = "0.4"
mime_guess = "2.0" mime_guess = "2.0"
once_cell = "1.20"
percent-encoding = "2.3" percent-encoding = "2.3"
rcgen = { version = "0.13.1", default-features = false, features = ["ring"] } rcgen = { version = "0.13.1", default-features = false, features = ["ring"] }
tokio-rustls = { version = "0.26.0", default-features = false, features = ["logging", "ring", "tls12"] } tokio-rustls = { version = "0.26.0", default-features = false, features = ["logging", "ring", "tls12"] }

View file

@ -7,7 +7,6 @@ use codes::*;
use metadata::{FileOptions, PresetMeta}; use metadata::{FileOptions, PresetMeta};
use { use {
once_cell::sync::Lazy,
percent_encoding::{percent_decode_str, percent_encode, AsciiSet, CONTROLS}, percent_encoding::{percent_decode_str, percent_encode, AsciiSet, CONTROLS},
rcgen::{CertificateParams, DnType, KeyPair}, rcgen::{CertificateParams, DnType, KeyPair},
std::{ std::{
@ -19,7 +18,7 @@ use {
io::Write as _, io::Write as _,
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}, net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},
path::{self, Component, Path, PathBuf}, path::{self, Component, Path, PathBuf},
sync::Arc, sync::{Arc, LazyLock},
}, },
tokio::{ tokio::{
io::{AsyncReadExt, AsyncWriteExt}, io::{AsyncReadExt, AsyncWriteExt},
@ -153,7 +152,7 @@ fn main() {
type Result<T = (), E = Box<dyn Error + Send + Sync>> = std::result::Result<T, E>; type Result<T = (), E = Box<dyn Error + Send + Sync>> = std::result::Result<T, E>;
static ARGS: Lazy<Args> = Lazy::new(|| { static ARGS: LazyLock<Args> = LazyLock::new(|| {
args().unwrap_or_else(|s| { args().unwrap_or_else(|s| {
eprintln!("{s}"); eprintln!("{s}");
std::process::exit(1); std::process::exit(1);
@ -409,7 +408,7 @@ fn check_path(s: String) -> Result<PathBuf, String> {
} }
/// TLS configuration. /// TLS configuration.
static TLS: Lazy<TlsAcceptor> = Lazy::new(acceptor); static TLS: LazyLock<TlsAcceptor> = LazyLock::new(acceptor);
fn acceptor() -> TlsAcceptor { fn acceptor() -> TlsAcceptor {
let config = if ARGS.only_tls13 { let config = if ARGS.only_tls13 {