Crate env_home

Source
Expand description

env_home is a general purpose crate for determining the current user home directory in a platform independant manner via enviornment variables.

This crate is implemented in pure-rust and has no external dependencies.

It is meant as a lightweight, drop-in replacement for std::env::home_dir provided by the Rust Standard Library which was deprecated in Rust 1.29.0 (Sept 2018).

§Usage

use env_home::env_home_dir as home_dir;
fn main() {
    match home_dir() {
        Some(path) => println!("User home directory: {}", path.display()),
        None => println!("No home found. HOME/USERPROFILE not set or empty"),
    }
}

Functions§

env_home_dir
Returns the path of the current user’s home directory if known.