diff options
| author | Abdul-Rahman Sibahi <asibahi@users.noreply.github.com> | 2024-10-31 14:52:11 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-31 11:52:11 +0000 |
| commit | b969c01b282287b44c3e131f8c0c53dcbb304e30 (patch) | |
| tree | fe58484bfa76e7fe7a35bf0bffdc339b24621693 /crates/typst-cli | |
| parent | 644ed252dda1a0785d2bee577a89322416f4d950 (diff) | |
Replace `once_cell`'s `Lazy` as much as possible (#4617)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'crates/typst-cli')
| -rw-r--r-- | crates/typst-cli/Cargo.toml | 1 | ||||
| -rw-r--r-- | crates/typst-cli/src/main.rs | 4 | ||||
| -rw-r--r-- | crates/typst-cli/src/world.rs | 7 |
3 files changed, 5 insertions, 7 deletions
diff --git a/crates/typst-cli/Cargo.toml b/crates/typst-cli/Cargo.toml index 855d7bee..2ecade54 100644 --- a/crates/typst-cli/Cargo.toml +++ b/crates/typst-cli/Cargo.toml @@ -36,7 +36,6 @@ ecow = { workspace = true } fs_extra = { workspace = true } native-tls = { workspace = true } notify = { workspace = true } -once_cell = { workspace = true } open = { workspace = true } parking_lot = { workspace = true } pathdiff = { workspace = true } diff --git a/crates/typst-cli/src/main.rs b/crates/typst-cli/src/main.rs index 464ad624..631befe5 100644 --- a/crates/typst-cli/src/main.rs +++ b/crates/typst-cli/src/main.rs @@ -16,12 +16,12 @@ mod world; use std::cell::Cell; use std::io::{self, Write}; use std::process::ExitCode; +use std::sync::LazyLock; use clap::error::ErrorKind; use clap::Parser; use codespan_reporting::term; use codespan_reporting::term::termcolor::WriteColor; -use once_cell::sync::Lazy; use typst::diag::HintedStrResult; use crate::args::{CliArguments, Command}; @@ -33,7 +33,7 @@ thread_local! { } /// The parsed command line arguments. -static ARGS: Lazy<CliArguments> = Lazy::new(|| { +static ARGS: LazyLock<CliArguments> = LazyLock::new(|| { CliArguments::try_parse().unwrap_or_else(|error| { if error.kind() == ErrorKind::DisplayHelpOnMissingArgumentOrSubcommand { crate::greet::greet(); diff --git a/crates/typst-cli/src/world.rs b/crates/typst-cli/src/world.rs index b790f41a..f3597544 100644 --- a/crates/typst-cli/src/world.rs +++ b/crates/typst-cli/src/world.rs @@ -1,12 +1,11 @@ use std::collections::HashMap; use std::io::Read; use std::path::{Path, PathBuf}; -use std::sync::OnceLock; +use std::sync::{LazyLock, OnceLock}; use std::{fmt, fs, io, mem}; use chrono::{DateTime, Datelike, FixedOffset, Local, Utc}; use ecow::{eco_format, EcoString}; -use once_cell::sync::Lazy; use parking_lot::Mutex; use typst::diag::{FileError, FileResult}; use typst::foundations::{Bytes, Datetime, Dict, IntoValue}; @@ -25,8 +24,8 @@ use crate::package; /// Static `FileId` allocated for stdin. /// This is to ensure that a file is read in the correct way. -static STDIN_ID: Lazy<FileId> = - Lazy::new(|| FileId::new_fake(VirtualPath::new("<stdin>"))); +static STDIN_ID: LazyLock<FileId> = + LazyLock::new(|| FileId::new_fake(VirtualPath::new("<stdin>"))); /// A world that provides access to the operating system. pub struct SystemWorld { |
