Safe interface to pwd.h
Homepage Repository Cargo Documentation Download
In the [dependencies] section of your Cargo.toml, add the following line:
[dependencies] pwd = "1"
In your crate root, add:
extern crate pwd;
extern crate pwd;
use pwd::Passwd;
fn main() {
let me = Passwd::current_user();
println!("my username is {}, home directory is {}, and my shell is {}. My uid/gid are {}/{}",
me.name, me.dir, me.shell, me.uid, me.gid);
}