Skip to content

Instantly share code, notes, and snippets.

@cmdln
Created August 18, 2017 16:31
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 cmdln/aba52ce5ad85a74848b35150f033e251 to your computer and use it in GitHub Desktop.
Save cmdln/aba52ce5ad85a74848b35150f033e251 to your computer and use it in GitHub Desktop.
Trying to deserialize and borrow
#[derive(Debug, Serialize, Deserialize)]
pub struct EnvVar<'a> {
name: &'a str,
default: &'a str,
optional: bool,
}:
#[derive(Debug, Serialize, Deserialize)]
pub struct Config<'a> {
#[serde(borrow)]
env_vars: Vec<env::EnvVar<'a>>,
}
pub fn load_config<'a>() -> Result<Config<'a>> {
let file = File::open("ctr.json")?;
let config: Config = serde_json::from_reader(file)?;
Ok(config)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment