知识卡片
Prelude自动引入名称
Prelude 是默认处于可用作用域的一组名称。例子可直接写 String::new(),使用标准 I/O 则先写 use std::io 或完整路径。导入影响名称的查找方式,模块里的实现仍由其定义位置决定。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 猜数字游戏 Setting Up a New Project · 查看原书依据
By default, Rust has a set of items defined in the standard library that it brings into the scope of every program. This set is called the prelude, and you can see everything in it at https://doc.rust-lang.org/std/prelude/index.html.
参考来源
- 位置:《The Rust Programming Language(第2版)》第02章 猜数字游戏(来源项目 a19c7933-4eda-4176-aebd-30fe7e1ad292,`extracted/The Rust Programming Language(第2版)/_epub-src/c02.xhtml`,块 0026)
- 结论依据:原文定义 prelude 并以 std::io 的显式引入作对照。
- 原始内容:By default, Rust has a set of items defined in the standard library that it brings into the scope of every program. This set is called the prelude, and you can see everything in it at https://doc.rust-lang.org/std/prelude/index.html.