How to declare constant in Rust

2 Answers

0 votes
fn main() {
    const LIMIT: i32 = 10000000;
    println!("{}", LIMIT);

    const PI: f64 = 3.14159265359 ;
    println!("{}", PI);
    
    const LANGUAGE: &str = "Rust";
    println!("{}", LANGUAGE);
}




/*
run:

10000000
3.14159265359
Rust


*/

 



answered Feb 5, 2023 by avibootz
edited Feb 5, 2023 by avibootz
0 votes
fn main() {
   let language: &'static str = "Rust Programming";
    
   println!("{}", language);
}
 
 
 
 
/*
run:
 
Rust Programming
 
*/

 



answered May 10, 2023 by avibootz

Related questions

...