Function is_root

Source
pub fn is_root() -> bool
Expand description

Returns true if user is root; false otherwise

use is_root::is_root;

if is_root() {
    println!("Doing something dangerous")
} else {
    eprintln!("Run me as root")
}
Examples found in repository?
examples/amiroot.rs (line 4)
3fn main() {
4    if is_root() {
5        println!("You are root");
6    } else {
7        println!("You are not root")
8    }
9}