Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Use (import) a name higher up in the hierarchy

There is also an option to include only part of the path in the use statement. In this case we will have to use the rest of the path in the code, but it will allow us to use multiple name (both PI and E in this case) using the shorter name.

use std::f32::consts::PI;
use std::f64::consts;

fn main() {
    println!("{}", PI);
    println!("{}", consts::PI);
    println!("{}", consts::E);
}
3.1415927
3.141592653589793
2.718281828459045