[][src]Function envy::prefixed

pub fn prefixed<'a, C>(prefix: C) -> Prefixed<'a> where
    C: Into<Cow<'a, str>>, 

Produces a instance of Prefixed for prefixing env variable names

Example

use serde::Deserialize;

#[derive(Deserialize, Debug)]
struct Config {
    foo: u16,
    bar: bool,
    baz: String,
    boom: Option<u64>,
}

// all env variables will be expected to be prefixed with APP_
// i.e. APP_FOO, APP_BAR, ect
match envy::prefixed("APP_").from_env::<Config>() {
    Ok(config) => println!("{:#?}", config),
    Err(error) => eprintln!("{:#?}", error),
}