Skip to content

Commit

Permalink
Merge pull request #583 from cgwalters/drop-oncecell
Browse files Browse the repository at this point in the history
lib: Drop our once_cell usage
  • Loading branch information
jeckersb committed Jun 4, 2024
2 parents 7ca74c0 + 2c07f5f commit dda4aaf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ indicatif = "0.17.8"
libc = "^0.2.154"
liboverdrop = "0.1.0"
libsystemd = "0.7"
once_cell = "1.19"
openssl = "^0.10.64"
# TODO drop this in favor of rustix
nix = { version = "0.28", features = ["ioctl", "sched"] }
Expand Down
7 changes: 4 additions & 3 deletions lib/src/blockdev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use anyhow::{anyhow, Context, Result};
use camino::{Utf8Path, Utf8PathBuf};
use fn_error_context::context;
use nix::errno::Errno;
use once_cell::sync::Lazy;
use regex::Regex;
use serde::Deserialize;
use std::collections::HashMap;
Expand All @@ -13,6 +12,7 @@ use std::fs::File;
use std::os::unix::io::AsRawFd;
use std::path::Path;
use std::process::Command;
use std::sync::OnceLock;

#[derive(Debug, Deserialize)]
struct DevicesOutput {
Expand Down Expand Up @@ -185,9 +185,10 @@ pub(crate) fn reread_partition_table(file: &mut File, retry: bool) -> Result<()>
/// Parse key-value pairs from lsblk --pairs.
/// Newer versions of lsblk support JSON but the one in CentOS 7 doesn't.
fn split_lsblk_line(line: &str) -> HashMap<String, String> {
static REGEX: Lazy<Regex> = Lazy::new(|| Regex::new(r#"([A-Z-_]+)="([^"]+)""#).unwrap());
static REGEX: OnceLock<Regex> = OnceLock::new();
let regex = REGEX.get_or_init(|| Regex::new(r#"([A-Z-_]+)="([^"]+)""#).unwrap());
let mut fields: HashMap<String, String> = HashMap::new();
for cap in REGEX.captures_iter(line) {
for cap in regex.captures_iter(line) {
fields.insert(cap[1].to_string(), cap[2].to_string());
}
fields
Expand Down

0 comments on commit dda4aaf

Please sign in to comment.