From 0bb488b80279c6fd2735cb356c38ecc1106ec4c1 Mon Sep 17 00:00:00 2001 From: vpgle <42811556+vpgle@users.noreply.github.com> Date: Sat, 12 Apr 2025 09:35:50 +0800 Subject: [PATCH] Update ch11-03-test-organization.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://doc.rust-lang.org/book/ch11-03-test-organization.html, In this test, we bring all of the tests module’s parent’s items into scope with use super::*, and then the test can call internal_adder. --- src/ch11-03-test-organization.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ch11-03-test-organization.md b/src/ch11-03-test-organization.md index d01a73a..32f4517 100644 --- a/src/ch11-03-test-organization.md +++ b/src/ch11-03-test-organization.md @@ -38,7 +38,7 @@ 示例 11-12:测试私有函数 -注意 `internal_adder` 函数并没有标记为 `pub`。测试也不过是 Rust 代码,同时 `tests` 也仅仅是另一个模块。正如 [“路径用于引用模块树中的项”][paths] 部分所说,子模块的项可以使用其上级模块的项。在测试中,我们通过 `use super::*` 将 `test` 模块的父模块的所有项引入了作用域,接着测试调用了 `internal_adder`。如果你并不认为应该测试私有函数,Rust 也不会强迫你这么做。 +注意 `internal_adder` 函数并没有标记为 `pub`。测试也不过是 Rust 代码,同时 `tests` 也仅仅是另一个模块。正如 [“路径用于引用模块树中的项”][paths] 部分所说,子模块的项可以使用其上级模块的项。在测试中,我们通过 `use super::*` 将 `tests` 模块的父模块的所有项引入了作用域,接着测试调用了 `internal_adder`。如果你并不认为应该测试私有函数,Rust 也不会强迫你这么做。 ### 集成测试