Skip to content

Commit

Permalink
remove dependency to lazy_static
Browse files Browse the repository at this point in the history
  • Loading branch information
stlankes committed Feb 17, 2025
1 parent 172bdd1 commit 416a713
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 22 deletions.
7 changes: 0 additions & 7 deletions 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ command-fds = "0.3"
futures = "0.3"
getset = "0.1"
goblin = { version = "0.9", default-features = false, features = ["elf64", "elf32", "endian_fd"] }
lazy_static = "1.5.0"
libc = "0.2"
log = { version = "0.4", features = ["std"] }
netlink-packet-core = "0.7"
Expand Down
25 changes: 11 additions & 14 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ use crate::spec::*;
use crate::start::*;
use crate::state::*;
use clap::{crate_version, Parser, Subcommand};
use lazy_static::lazy_static;
use serde::Deserialize;
use std::fs::DirBuilder;
use std::os::unix::fs::DirBuilderExt;
use std::sync::LazyLock;
use std::{env, path::PathBuf};

/// This is what we're going to decode into. Each field is optional, meaning
Expand All @@ -55,21 +55,18 @@ impl Config {
}
}

lazy_static! {
static ref CONFIG: Config = {
match std::fs::read_to_string("/etc/runh/config.toml") {
Ok(content) => {
let decoded: Result<Config, toml::de::Error> = toml::from_str(&content);
if let Ok(config) = decoded {
config
} else {
Config::new()
}
static CONFIG: LazyLock<Config> =
LazyLock::new(|| match std::fs::read_to_string("/etc/runh/config.toml") {
Ok(content) => {
let decoded: Result<Config, toml::de::Error> = toml::from_str(&content);
if let Ok(config) = decoded {
config
} else {
Config::new()
}
Err(_) => Config::new(),
}
};
}
Err(_) => Config::new(),
});

fn parse_matches(cli: &Cli) {
let project_dir = &cli.root;
Expand Down

0 comments on commit 416a713

Please sign in to comment.