元组(Tuples)

fn main() {
    let t: (i8, bool) = (7, true);
    println!("t.0: {}", t.0);
    println!("t.1: {}", t.1);
}
  • 和数组一样,元组也具有固定的长度。

  • 元组将不同类型的值组成一个复合类型。

  • 元组中的字段可以通过英文句号加上值的下标进行访问比如:t.0, t.1

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