Skip to content

Instantly share code, notes, and snippets.

Created April 5, 2016 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/236158b5e9073195a5bec65343fd828a to your computer and use it in GitHub Desktop.
Save anonymous/236158b5e9073195a5bec65343fd828a to your computer and use it in GitHub Desktop.
Shared via Rust Playground
use std::path::{PathBuf ,Path};
use std::env;
use std::fmt;
lazy_static! {
pub static ref HOME: PathBuf = get_home();
}
pub fn get_home() -> PathBuf {
// mockup
PathBuf::from("/home/myuser")
}
pub struct Params<'a> {
pub home : &'a HOME,
pub dbs : Vec<String>,
/* some more fields
*/
}
pub fn setup_parms(home: &HOME ) -> Params {
let p = Params {
home: &home,
dbs: vec!["jasd".to_string(),"asdf".to_string()],
};
p
}
lazy_static! {
pub static ref PARAMETER: Params<'static> = setup_parms(&HOME);
}
impl fmt::Debug for PARAMETER {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.home.to_str());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment