Skip to content

Commit

Permalink
Remove once_cell dependency
Browse files Browse the repository at this point in the history
Remove the once_cell dependency now that similar functionality is
provided by the standard library.
  • Loading branch information
d-e-s-o committed Dec 21, 2024
1 parent 4e99dad commit 4304d34
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ grev = "0.1.3"
anyhow = "1.0.68"
clap = {version = "4.1.4", features = ["derive"]}
clap_complete = {version = "4.1.1", optional = true}
once_cell = "1.17.0"
regex = {version = "1.7.1", default-features = false, features = ["std"]}
tempfile = {version = "3.3.0", optional = true}
time = {version = "0.3.18", features = ["formatting", "local-offset", "parsing"]}
Expand Down
5 changes: 2 additions & 3 deletions src/btrfs/btrfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ use std::path::PathBuf;
use std::str::FromStr as _;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering;
use std::sync::LazyLock;

use anyhow::Context as _;
use anyhow::Result;

use once_cell::sync::Lazy;

use regex::Regex;

use crate::ops::FileOps;
Expand All @@ -40,7 +39,7 @@ const PATH_STRING: &str = r".+";
/// by the snapshots() method. Each line is expected to be following the
/// pattern:
/// ID A gen B top level C path PATH
static SNAPSHOTS_LINE_REGEX: Lazy<Regex> = Lazy::new(|| {
static SNAPSHOTS_LINE_REGEX: LazyLock<Regex> = LazyLock::new(|| {
Regex::new(&format!(
r"^ID {NUMS_STRING} gen (?P<gen>{NUMS_STRING}) top level {NUMS_STRING} path (?P<path>{PATH_STRING})$"
)).expect("failed to create snapshot regular expression")
Expand Down
7 changes: 3 additions & 4 deletions src/snapshot.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2023 Daniel Mueller <deso@posteo.net>
// Copyright (C) 2023-2024 Daniel Mueller <deso@posteo.net>
// SPDX-License-Identifier: GPL-3.0-or-later

use std::borrow::Cow;
Expand All @@ -10,13 +10,12 @@ use std::fmt::Result as FmtResult;
use std::path::Path;
use std::path::MAIN_SEPARATOR;
use std::str::FromStr as _;
use std::sync::LazyLock;

use anyhow::ensure;
use anyhow::Context as _;
use anyhow::Result;

use once_cell::sync::Lazy;

use time::format_description::modifier::Day;
use time::format_description::modifier::Hour;
use time::format_description::modifier::Minute;
Expand Down Expand Up @@ -52,7 +51,7 @@ const ENCODED_INTRA_COMPONENT_SEPARATOR: &str = "-";
const ENCODED_COMPONENT_SEPARATOR: &str = "_";

/// The UTC time zone offset we use throughout the program.
static UTC_OFFSET: Lazy<UtcOffset> = Lazy::new(|| {
static UTC_OFFSET: LazyLock<UtcOffset> = LazyLock::new(|| {
if cfg!(test) || cfg!(feature = "test") {
// SAFETY: Our tests do not mutate the environment.
let () = unsafe { set_soundness(Soundness::Unsound) };
Expand Down

0 comments on commit 4304d34

Please sign in to comment.