元組

fn main() {
    let t: (i8, bool) = (7, true);
    println!("t.0: {}", t.0);
    println!("t.1: {}", t.1);
}
This slide should take about 5 minutes.
  • 和陣列一樣,元組有固定的長度。

  • 元組會將不同型別的值組成複合型別。

  • 元組的欄位可透過點號和值的索引存取,例如 t.0t.1

  • The empty tuple () is referred to as the "unit type" and signifies absence of a return value, akin to void in other languages.