Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacement of lazy_static with std::sync::OnceLock #61

Merged
merged 2 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ path = "src/main.rs"
name = "bookmark-cd"

[dependencies]
lazy_static = "1.4.0"
clap = { version = "4.4", features = ["derive"] }
csv = "1.2"
home = "0.5.5"
Expand Down
22 changes: 11 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use clap::Parser;
use csv::{Reader, Result, Writer};
use home::home_dir;
use lazy_static::lazy_static;
use std::env;
use std::path::Path;
use std::process::exit;
use std::{collections::BTreeMap, env::current_dir};
use std::{
collections::BTreeMap, env, env::current_dir, path::Path, process::exit, sync::OnceLock,
};

use tabled::{
builder::Builder, settings::object::Segment, settings::Alignment, settings::Modify,
settings::Style,
Expand Down Expand Up @@ -34,12 +33,13 @@ fn main() {

let options = cli::Options::parse();

lazy_static! {
static ref DESCRIPTION: String = format!(
static DESCRIPTION: OnceLock<String> = OnceLock::new();
DESCRIPTION.get_or_init(|| {
format!(
"bcd {}: bookmark directories and move to them.",
env!("CARGO_PKG_VERSION")
);
};
)
});

if options.install {
// a way to try to set up the shell when the data file exists but the `bcd` function is not.
Expand All @@ -51,7 +51,7 @@ fn main() {
}

if options.version {
println!("{}", DESCRIPTION.as_str());
println!("{}", DESCRIPTION.get().unwrap().as_str());
exit(0);
}

Expand Down Expand Up @@ -158,7 +158,7 @@ fn main() {
exit(0);
}

println!("{}", DESCRIPTION.as_str());
println!("{}", DESCRIPTION.get().unwrap().as_str());
}
}

Expand Down