rustlings

solving rustlings ft. dracuxan
git clone [email protected]:dracuxan/rustlings.git
Log | Files | Refs

variables2.rs (463B)


      1 fn main() {
      2     // The easiest way to fix the compiler error is to initialize the
      3     // variable `x`. By setting its value to an integer, Rust infers its type
      4     // as `i32` which is the default type for integers.
      5     let x = 42;
      6 
      7     // But we can enforce a type different from the default `i32` by adding
      8     // a type annotation:
      9     // let x: u8 = 42;
     10 
     11     if x == 10 {
     12         println!("x is ten!");
     13     } else {
     14         println!("x is not ten!");
     15     }
     16 }