0

Rust – Environment Variables

In Rust, we could get, list, or update environment variables using functions provided in the std::env module.

List Environment Variables

Output

Get Environment Variable

If CARGO_HOME  was undefined and we did not have the if-else  statement, we would have this run-time error:

Set Environment Variable

Output

Delete an Environment Variable

Output

Test with Rust 1.38.0.

Karl San Gabriel

Karl San Gabriel

Professional Software Developer