Skip to main content

var_parse_opt

Function var_parse_opt 

Source
pub fn var_parse_opt<T>(name: &str) -> Result<Option<T>>
where T: FromStr, T::Err: Display,
Expand description

Get an optional environment variable parsed as a specific type

§Returns

  • Ok(Some(value)) if the variable exists and parses successfully
  • Ok(None) if the variable doesn’t exist
  • Err(EnvError::ParseError) if the variable exists but can’t be parsed

§Errors

  • If the environment variable exists but cannot be parsed to the target type