知识卡片
元组以位置组合类型
元组用位置承载异构值,例如 (i32, f64)。可用 let (a, b) = pair 解构或通过 .0 访问。位置多且语义容易混淆时,用命名字段能让消费端看到含义。空元组 () 表示单元值。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 常见编程概念 Compound Types · 查看原书依据
A tuple is a general way of grouping together a number of values with a variety of types into one compound type. Tuples have a fixed length: once declared, they cannot grow or shrink in size.
参考来源
- 位置:《The Rust Programming Language(第2版)》第03章 常见编程概念(来源项目 a19c7933-4eda-4176-aebd-30fe7e1ad292,`extracted/The Rust Programming Language(第2版)/_epub-src/c03.xhtml`,块 0112)
- 结论依据:原文定义元组定长且可以组合不同类型的值。
- 原始内容:A tuple is a general way of grouping together a number of values with a variety of types into one compound type. Tuples have a fixed length: once declared, they cannot grow or shrink in size.