 Rust 程序设计语言 简体中文版 1.85.0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 7.3. 引用模块树中项的路径 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (namespace)下,而不需要使用类似 string_from 这样的名字。在第五章的 “方法语 法”(“Method Syntax”) 部分会着重讲解这个语法,而且在第七章的 “路径用于引用模块树中 的项” 中会讲到模块的命名空间。 let mut s = String::from("hello"); s.push_str(", world!"); // push_str() src/lib.rs 叫做 crate 根。之所以这样叫它们是因为这两 个文件的内容都分别在 crate 模块结构的根组成了一个名为 crate 的模块,该结构被称为模块 树(module tree)。 示例 7-2 展示了示例 7-1 中模块树的结构。 crate └── front_of_house ├── hosting │ ├── add_to_waitlist0 码力 | 562 页 | 3.23 MB | 26 天前3 Rust 程序设计语言 简体中文版 1.85.0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 7.3. 引用模块树中项的路径 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (namespace)下,而不需要使用类似 string_from 这样的名字。在第五章的 “方法语 法”(“Method Syntax”) 部分会着重讲解这个语法,而且在第七章的 “路径用于引用模块树中 的项” 中会讲到模块的命名空间。 let mut s = String::from("hello"); s.push_str(", world!"); // push_str() src/lib.rs 叫做 crate 根。之所以这样叫它们是因为这两 个文件的内容都分别在 crate 模块结构的根组成了一个名为 crate 的模块,该结构被称为模块 树(module tree)。 示例 7-2 展示了示例 7-1 中模块树的结构。 crate └── front_of_house ├── hosting │ ├── add_to_waitlist0 码力 | 562 页 | 3.23 MB | 26 天前3
共 1 条
- 1













