Created
August 18, 2017 16:31
-
-
Save cmdln/aba52ce5ad85a74848b35150f033e251 to your computer and use it in GitHub Desktop.
Trying to deserialize and borrow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[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