https://doc.rust-lang.org/std/env/index.html

std::env - Rust

Expand description

Inspection and manipulation of the process’s environment.

This module contains functions to inspect various aspects such as environment variables, process arguments, the current directory, and various other important directories.

There are several functions and structs in this module that have a counterpart ending in os. Those ending in os will return an OsString and those without will return a String.

constsConstants associated with the current targetArgsAn iterator over the arguments of a process, yielding a String value for each argument.ArgsOsAn iterator over the arguments of a process, yielding an OsString value for each argument.JoinPathsErrorThe error type for operations on the PATH variable. Possibly returned from env::join_paths().SplitPathsAn iterator that splits an environment variable into paths according to platform-specific conventions.VarsAn iterator over a snapshot of the environment variables of this process.VarsOsAn iterator over a snapshot of the environment variables of this process.VarErrorThe error type for operations interacting with environment variables. Possibly returned from env::var().argsReturns the arguments that this program was started with (normally passed via the command line).args_osReturns the arguments that this program was started with (normally passed via the command line).current_dirReturns the current working directory as a PathBuf.current_exeReturns the full filesystem path of the current running executable.home_dir DeprecatedReturns the path of the current user’s home directory if known.join_pathsJoins a collection of Path s appropriately for the PATH environment variable.remove_var ⚠Removes an environment variable from the environment of the currently running process.set_current_dirChanges the current working directory to the specified path.set_var ⚠Sets the environment variable key to the value value for the currently running process.split_pathsParses input according to platform conventions for the PATH environment variable.temp_dirReturns the path of a temporary directory.varFetches the environment variable key from the current process.var_osFetches the environment variable key from the current process, returning None if the variable isn’t set or if there is another error.varsReturns an iterator of (variable, value) pairs of strings, for all the environment variables of the current process.vars_osReturns an iterator of (variable, value) pairs of OS strings, for all the environment variables of the current process.