refactor: remove once_cell dependency and use std::sync equivalents (#4185)
This commit is contained in:
1 parent
1d954c2f6f
commit
3c3256ec02
22 files changed
+22
-47
No files matched your search
@@ -71,7 +71,6 @@ dunce = { workspace = true }
|
||||
dirs = { workspace = true }
|
||||
reqwest = { workspace = true, features = ["rustls-tls", "trust-dns", "json"] }
|
||||
tower = { workspace = true }
|
||||
once_cell = { workspace = true }
|
||||
|
||||
# path lookup
|
||||
which = { version = "7.0.2" }
|
||||
|
||||
@@ -3532,10 +3532,10 @@ impl BuildRequest {
|
||||
///
|
||||
/// It's not guaranteed that they're different from any other folder
|
||||
pub(crate) fn prepare_build_dir(&self) -> Result<()> {
|
||||
use once_cell::sync::OnceCell;
|
||||
use std::fs::{create_dir_all, remove_dir_all};
|
||||
use std::sync::OnceLock;
|
||||
|
||||
static INITIALIZED: OnceCell<Result<()>> = OnceCell::new();
|
||||
static INITIALIZED: OnceLock<Result<()>> = OnceLock::new();
|
||||
|
||||
let success = INITIALIZED.get_or_init(|| {
|
||||
if self.platform != Platform::Server {
|
||||
|
||||
@@ -242,14 +242,14 @@ fn remove_triple_newlines(string: &str) -> String {
|
||||
// #[cfg(test)]
|
||||
// pub(crate) mod tests {
|
||||
// use escargot::{CargoBuild, CargoRun};
|
||||
// use once_cell::sync::Lazy;
|
||||
// use std::sync::LazyLock;
|
||||
// use std::fs::{create_dir_all, read_to_string};
|
||||
// use std::path::{Path, PathBuf};
|
||||
// use std::process::Command;
|
||||
// use tempfile::tempdir;
|
||||
// use toml::Value;
|
||||
|
||||
// static BINARY: Lazy<CargoRun> = Lazy::new(|| {
|
||||
// static BINARY: LazyLock<CargoRun> = LazyLock::new(|| {
|
||||
// CargoBuild::new()
|
||||
// .bin(env!("CARGO_BIN_NAME"))
|
||||
// .current_release()
|
||||
|
||||
@@ -24,8 +24,8 @@ use crate::{error::Result, Error, StructuredOutput};
|
||||
use clap::builder::styling::{AnsiColor, Effects, Style, Styles};
|
||||
use clap::{Parser, Subcommand};
|
||||
use html_parser::Dom;
|
||||
use once_cell::sync::Lazy;
|
||||
use serde::Deserialize;
|
||||
use std::sync::LazyLock;
|
||||
use std::{
|
||||
fmt::Display,
|
||||
fs::File,
|
||||
@@ -123,7 +123,7 @@ impl Display for Commands {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) static VERSION: Lazy<String> = Lazy::new(|| {
|
||||
pub(crate) static VERSION: LazyLock<String> = LazyLock::new(|| {
|
||||
format!(
|
||||
"{} ({})",
|
||||
crate::dx_build_info::PKG_VERSION,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::*;
|
||||
use crate::{AddressArguments, BuildArgs, TraceController};
|
||||
use futures_util::FutureExt;
|
||||
use once_cell::sync::OnceCell;
|
||||
use std::sync::OnceLock;
|
||||
use std::{backtrace::Backtrace, panic::AssertUnwindSafe};
|
||||
|
||||
/// Serve the project
|
||||
@@ -102,7 +102,7 @@ impl ServeArgs {
|
||||
line: u32,
|
||||
column: u32,
|
||||
}
|
||||
static BACKTRACE: OnceCell<(Backtrace, Option<SavedLocation>)> = OnceCell::new();
|
||||
static BACKTRACE: OnceLock<(Backtrace, Option<SavedLocation>)> = OnceLock::new();
|
||||
|
||||
// We *don't* want printing here, since it'll break the tui and log ordering.
|
||||
//
|
||||
|
||||
@@ -18,7 +18,7 @@ use crate::{serve::ServeUpdate, Cli, Commands, Platform as TargetPlatform, Verbo
|
||||
use cargo_metadata::diagnostic::{Diagnostic, DiagnosticLevel};
|
||||
use clap::Parser;
|
||||
use futures_channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender};
|
||||
use once_cell::sync::OnceCell;
|
||||
use std::sync::OnceLock;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
env,
|
||||
@@ -47,8 +47,8 @@ const LOG_FILE_NAME: &str = "dx.log";
|
||||
const DX_SRC_FLAG: &str = "dx_src";
|
||||
|
||||
static TUI_ACTIVE: AtomicBool = AtomicBool::new(false);
|
||||
static TUI_TX: OnceCell<UnboundedSender<TraceMsg>> = OnceCell::new();
|
||||
pub static VERBOSITY: OnceCell<Verbosity> = OnceCell::new();
|
||||
static TUI_TX: OnceLock<UnboundedSender<TraceMsg>> = OnceLock::new();
|
||||
pub static VERBOSITY: OnceLock<Verbosity> = OnceLock::new();
|
||||
|
||||
pub(crate) struct TraceController {
|
||||
pub(crate) tui_rx: UnboundedReceiver<TraceMsg>,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::{Result, TraceSrc};
|
||||
use once_cell::sync::Lazy;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::sync::LazyLock;
|
||||
use std::{fs, path::PathBuf, sync::Arc};
|
||||
use tracing::{error, trace, warn};
|
||||
|
||||
@@ -33,8 +33,8 @@ pub(crate) struct CliSettings {
|
||||
impl CliSettings {
|
||||
/// Load the settings from the local, global, or default config in that order
|
||||
pub(crate) fn load() -> Arc<Self> {
|
||||
static SETTINGS: Lazy<Arc<CliSettings>> =
|
||||
Lazy::new(|| Arc::new(CliSettings::global_or_default()));
|
||||
static SETTINGS: LazyLock<Arc<CliSettings>> =
|
||||
LazyLock::new(|| Arc::new(CliSettings::global_or_default()));
|
||||
SETTINGS.clone()
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user