Skip to content

Commit

Permalink
Replace once_cell with LazyLock
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrubeck committed Sep 16, 2024
1 parent de24f1d commit 04e4eae
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
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.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ getopts = "0.2.21"
glob = "0.3"
log = "0.4"
mime_guess = "2.0"
once_cell = "1.20"
percent-encoding = "2.3"
rcgen = { version = "0.13.1", default-features = false, features = ["ring"] }
tokio-rustls = { version = "0.26.0", default-features = false, features = ["logging", "ring", "tls12"] }
Expand Down
7 changes: 3 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use codes::*;
use metadata::{FileOptions, PresetMeta};

use {
once_cell::sync::Lazy,
percent_encoding::{percent_decode_str, percent_encode, AsciiSet, CONTROLS},
rcgen::{CertificateParams, DnType, KeyPair},
std::{
Expand All @@ -19,7 +18,7 @@ use {
io::Write as _,
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},
path::{self, Component, Path, PathBuf},
sync::Arc,
sync::{Arc, LazyLock},
},
tokio::{
io::{AsyncReadExt, AsyncWriteExt},
Expand Down Expand Up @@ -153,7 +152,7 @@ fn main() {

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| {
eprintln!("{s}");
std::process::exit(1);
Expand Down Expand Up @@ -409,7 +408,7 @@ fn check_path(s: String) -> Result<PathBuf, String> {
}

/// TLS configuration.
static TLS: Lazy<TlsAcceptor> = Lazy::new(acceptor);
static TLS: LazyLock<TlsAcceptor> = LazyLock::new(acceptor);

fn acceptor() -> TlsAcceptor {
let config = if ARGS.only_tls13 {
Expand Down

0 comments on commit 04e4eae

Please sign in to comment.