pub fn is_root() -> bool
Returns true if user is root; false otherwise
true
false
use is_root::is_root; if is_root() { println!("Doing something dangerous") } else { eprintln!("Run me as root") }
3 4 5 6 7 8 9
fn main() { if is_root() { println!("You are root"); } else { println!("You are not root") } }