知识卡片
泛型共用数据形状
泛型结构把字段类型的一部分变成参数。Complex<T> 的实部、虚部都用 T,Complex<f32> 与 Complex<f64> 共用结构定义而分量精度不同。Option<T> 同样能保持有值或缺席的形状,把被包装的值类型留给使用者。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- A Tour of Rust 用迭代预算近似分形边界 · 查看原书依据
Complex is a generic structure: you can read the <T> after the type name as “for any type T.” For example, Complex<f64> is
参考来源
- 位置:《Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)》第01章《A Tour of Rust》|用迭代预算近似分形边界,来源项目 `book-source`,`extracted/Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)/_epub-src/OEBPS/ch01.xhtml#what-the-mandelbrot-set-actually-is`
- 结论依据:原文以 Complex 的两个同类型字段解释结构体参数。
- 原始内容:Complex is a generic structure: you can read the <T> after the type name as “for any type T.” For example, Complex<f64> is