[−][src]Function envmnt::set_optional
pub fn set_optional<K: AsRef<OsStr>, V: AsRef<OsStr>>(
key: K,
value: &Option<V>
) -> bool
Sets the environment variable if the provided option contains a value.
Arguments
key
- The environment variable namevalue
- The optional value to set
Example
fn main() { let output = envmnt::set_optional("MY_ENV_VAR", &Some("OPTIONAL VALUE")); assert!(output); assert!(envmnt::is_equal( "MY_ENV_VAR", "OPTIONAL VALUE" )); }