知识卡片

普通读书笔记卡 · 6074.c

聚合类型区分形状

理解等级:中级

数组组合固定数量的同型元素,元组组合固定位置的异型元素,结构体为组合及字段提供名称。选择应看形状和角色:若元组里的多个i32、bool难以辨认,具名字段能减少位置误用。这里描述的是类型表达,不承诺所有结构体采用某种固定内存布局。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Chapter 1. Types Aggregate Types · 查看原书依据

      Arrays Hold multiple instances of a single type, where the number of instances is known at compile time. For example, [u32; 4] is four 4-byte integers in a row. Tuples Hold instances of multiple heterogeneous types, where the number of elements and their types are known at compile time, for example, (WidgetOffset, WidgetSize, WidgetColor). If the types in th

    参考来源

    - 位置:《Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)》第1章《Aggregate Types》(spine5;extracted/Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)/_epub-src/OEBPS/ch01.html;u009-ch01-004)。 - 结论依据:原文在“Arrays”附近的定义、例子或代码支撑本卡核心说明:数组组合固定数量的同型元素,元组组合固定位置的异型元素,结构体为组合及字段提供名称。边界按已读前提解释;示例未执行。 - 原始内容:Arrays Hold multiple instances of a single type, where the number of instances is known at compile time. For example, [u32; 4] is four 4-byte integers in a row. Tuples Hold instances of multiple heterogeneous types, where the number of elements and their types are known at compile time, for example, (WidgetOffset, WidgetSize, WidgetColor). If the types in th