I am new to Rust. I am creating a Rust binary that takes a command line argument. I want to be able to use the command line argument string as a static constant string for the entirety of the application.
What is the right approach to doing that?
If I declare something static and I update it I am having to use unsafe everywhere I use it.
If I use lazy_static like below, I am not sure how to make the locally acquired &argv[1] accessible to a closure declared inside main
lazy_static! {
static ref MYID: String = get_arg_value();
}
fn main() {
let argsv: Vec<String> = std::env::args().collect();
let get_arg_value = || -> String { argsv[1] }
}