Constants

Constants in Rust are defined using const keyword but datatype should be defined explicitly for the variable with any scope. Global scope is also possible.

Filename: src/main.rs

const PI: f64 = 3.1428;
fn main() {
    println!("The value of PI is: {PI}");

}

Last updated