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

Using a library with an alias

  • as
  • alias

If for some reason we really need to use the same name from two different libraries, we can use the as keyword to rename one of them for our project. To give it an alias.

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

fn main() {
    println!("{}", PI);
    println!("{}", bigPI);
}
3.1415927
3.141592653589793