Logo

Programming-Idioms

History of Idiom 205 > diff from v28 to v29

Edit summary for version 29 by Plecra:
New Rust implementation by user [Plecra]

Version 28

2020-07-12, 00:25:04

Version 29

2020-07-14, 18:54:13

Idiom #205 Get an environment variable

Read an environment variable with the name "FOO" and assign it to the string variable foo. If it does not exist or if the system does not support environment variables, assign a value of "none".

Idiom #205 Get an environment variable

Read an environment variable with the name "FOO" and assign it to the string variable foo. If it does not exist or if the system does not support environment variables, assign a value of "none".

Variables
foo
Variables
foo
Extra Keywords
envvar os system
Extra Keywords
envvar os system
Code
let foo = std::env::var("FOO").unwrap_or_else(|| "none".into());
Doc URL
https://doc.rust-lang.org/std/env/fn.var.html