osOperating system interfaces.
Access command-line arguments, environment variables, and system information.
import std::os;
fn main() {
let n = os.args_count();
let first = os.args(0);
let home = os.home_dir();
println(home);
}
args_countReturns the number of command-line arguments.
argsReturns the command-line argument at the given index.
Index 0 is the program name. Panics if index is out of range.
let program = os.args(0);
let first_arg = os.args(1);
envGet the value of an environment variable.
Returns an empty string if the variable is not set.
let path = os.env("PATH");
set_envSet an environment variable for the current process.
remove_envRemove an environment variable.
has_envCheck whether an environment variable is set.
cwdReturns the current working directory.
home_dirReturns the user's home directory.
hostnameReturns the system hostname.
pidReturns the current process ID.