Remove once_cell

This commit is contained in:
Luca Palmieri 2024-08-29 17:12:38 +02:00
parent 25316873d5
commit 9a7c584434
3 changed files with 3 additions and 5 deletions

1
Cargo.lock generated
View file

@ -3349,7 +3349,6 @@ dependencies = [
"config",
"fake",
"log",
"once_cell",
"quickcheck",
"quickcheck_macros",
"reqwest",

View file

@ -50,4 +50,3 @@ wiremock = "0.6"
serde_json = "1.0.61"
claims = "0.7"
reqwest = { version = "0.12", features = ["json"] }
once_cell = "1.7.2"

View file

@ -1,6 +1,6 @@
use once_cell::sync::Lazy;
use sqlx::{Connection, Executor, PgConnection, PgPool};
use std::net::TcpListener;
use std::sync::LazyLock;
use uuid::Uuid;
use zero2prod::configuration::{get_configuration, DatabaseSettings};
use zero2prod::email_client::EmailClient;
@ -8,7 +8,7 @@ use zero2prod::startup::run;
use zero2prod::telemetry::{get_subscriber, init_subscriber};
// Ensure that the `tracing` stack is only initialised once using `once_cell`
static TRACING: Lazy<()> = Lazy::new(|| {
static TRACING: LazyLock<()> = LazyLock::new(|| {
let default_filter_level = "info".to_string();
let subscriber_name = "test".to_string();
if std::env::var("TEST_LOG").is_ok() {
@ -28,7 +28,7 @@ pub struct TestApp {
async fn spawn_app() -> TestApp {
// The first time `initialize` is invoked the code in `TRACING` is executed.
// All other invocations will instead skip execution.
Lazy::force(&TRACING);
LazyLock::force(&TRACING);
let listener = TcpListener::bind("127.0.0.1:0").expect("Failed to bind random port");
// We retrieve the port assigned to us by the OS