Skip to content

Commit

Permalink
Update input_parameters.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouYong10 authored Jun 27, 2024
1 parent 0cb07db commit 46d00da
Showing 1 changed file with 1 addition and 1 deletion.
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

0 comments on commit 46d00da

Please sign in to comment.