Hi Rustaceans, i'm developing a GTK+ 3 application and need to set and keep track of key-value pairs globally in a helper module. So, this is what i came up with initially:
use std::env;
use std::string::String;
pub fn get_env(key: String) -> String {
let val = env::var(key).unwrap();
val;
}
pub fn set_env(key: &String, val: &String) {
env::set_var(key, val);
}
However, this feels hacky and i don't want to mess up with the environment variables this way. So, is there a better approach for keeping the global vars somewhere? Maybe Gtk-rs module provides an helper function or something for achieving this? Thanks in advance!