xur_

> module

std::env

environment variables and process paths

use std::env; feature env native only

std::env provides access to environment variables and process-related paths.

> functions

# current_dir() -> Result<str, Error>

The current working directory, or an io::Error if it can't be read.

# exe_path() -> Option<str>

The path of the running executable, or None if it can't be found.

# get(name: str) -> Option<str>

Read an environment variable. Returns None if not set.

# home_dir() -> Option<str>

The value of $HOME, or None if it isn't set.

# remove(name: str)

Unset an environment variable.

# set(name: str, value: str)

Set an environment variable for this process and the programs it starts.

# vars() -> list<list<str>>

All environment variables, as a list of [name, value] pairs.

> examples

use std::env;
use std::io;

fn main() {
    env::set("MY_VAR", "hello");
    io::println("MY_VAR = {}", env::get("MY_VAR").unwrap());
    io::println("cwd: {}", env::current_dir().unwrap());
}