Skip to content

Commit

Permalink
Use LazyCell
Browse files Browse the repository at this point in the history
  • Loading branch information
j178 committed Oct 20, 2024
1 parent f4d5fba commit 305d4bb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/uv-auth/src/middleware.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::sync::{Arc, LazyLock};
use std::cell::LazyCell;
use std::sync::Arc;

use http::{Extensions, StatusCode};
use url::Url;
Expand All @@ -16,14 +17,14 @@ use tracing::{debug, trace, warn};

/// Strategy for loading netrc files.
enum NetrcMode {
Automatic(LazyLock<Option<Netrc>>),
Automatic(LazyCell<Option<Netrc>>),
Enabled(Netrc),
Disabled,
}

impl Default for NetrcMode {
fn default() -> Self {
NetrcMode::Automatic(LazyLock::new(|| match Netrc::new() {
NetrcMode::Automatic(LazyCell::new(|| match Netrc::new() {
Ok(netrc) => Some(netrc),
Err(netrc::Error::Io(err)) if err.kind() == std::io::ErrorKind::NotFound => {
debug!("No netrc file found");
Expand Down

0 comments on commit 305d4bb

Please sign in to comment.