← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 10647.c · 生成模型:未记录

单态化生成具体实现

理解等级:中级

Rust 编译器对实际用到的具体类型实例化泛型代码。用到 Option 和 Option 时,各自可以有针对其数据类型的实现和布局。运行时代码已知道具体类型,泛型本身不需要再查找类型来执行。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《The Rust Programming Language(第2版)》第10章 泛型类型、trait 与生命周期(来源项目 a19c7933-4eda-4176-aebd-30fe7e1ad292,`extracted/The Rust Programming Language(第2版)/_epub-src/c10.xhtml`,块 0097) - 结论依据:原文定义单态化并说明它发生在编译期。 - 原始内容:Rust accomplishes this by performing monomorphization of the code using generics at compile time. Monomorphization is the process of turning generic code into specific code by filling in the concrete types that are used when compiled.