Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update input_parameters.md #195

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/fn/closures/input_parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

例如用一个类型说明为 `FnOnce` 的闭包作为参数。这说明闭包可能采取 `&T`,`&mut T` 或 `T` 中的一种捕获方式,但编译器最终是根据所捕获变量在闭包里的使用情况决定捕获方式。

这是因为如果能以移动的方式捕获变量,则闭包也有能力使用其他方式借用变量。注意反过来就不再成立:如果参数的类型说明是 `Fn`,那么不允许该闭包通过 `&mut T` 或 `T` 捕获变量。
这是因为如果能以移动的方式捕获变量,则闭包也有能力使用其他方式借用变量。注意反过来就不再成立:如果参数的类型说明是 `Fn`,那么不允许该闭包通过 `&mut T` 或 `&T` 捕获变量。

在下面的例子中,试着分别用一用 `Fn`、`FnMut` 和 `FnOnce`,看看会发生什么:

Expand Down