Rust-01

61 阅读1分钟
  • Integer&Float
8-biti8u8
16-biti16u16
32-biti32u32
64-biti64u64
128-biti128u128
archisizeusize
f32
f64
  • Char
fn main() {
    let c = 'z';
    let z: char = 'ℤ'; // with explicit type annotation
    let heart_eyed_cat = '😻';
}
  • Tuple
fn main() {
    let tup = (500, 6.4, 1);

    let (x, y, z) = tup;

    println!("The value of y is: {y}");
}
  • Array
let a: [i32; 5] = [1, 2, 3, 4, 5];
let a = [3; 5];//let a = [3, 3, 3, 3, 3]