Function itconfig::maybe_get_env[][src]

pub fn maybe_get_env<T>(env_name: &str) -> Option<T> where
    T: FromEnvString
Expand description

Same as get_env but returns Option enum instead Result

Example

use std::env;

fn main () {
    env::set_var("HOST", "https://example.com");

    let host: Option<&'static str> = maybe_get_env("HOST");
    let not_existence_host: Option<&'static str> = maybe_get_env("NOT_EXISTENCE_HOST");

    assert_eq!(host, Some("https://example.com"));
    assert_eq!(not_existence_host, None);
}