Skip to content

Commit af6f03f

Browse files
authored
Merge pull request #1496 from slanterns/master
Fix the inaccurate rule of `Fn` trait inference in `fn/closures/input_parameters.md`
2 parents 107001e + d790952 commit af6f03f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/fn/closures/input_parameters.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
While Rust chooses how to capture variables on the fly mostly without type
44
annotation, this ambiguity is not allowed when writing functions. When
55
taking a closure as an input parameter, the closure's complete type must be
6-
annotated using one of a few `traits`. In order of decreasing restriction,
6+
annotated using one of a few `traits`, and they're determined by what the
7+
closure does with captured value. In order of decreasing restriction,
78
they are:
89

9-
* `Fn`: the closure captures by reference (`&T`)
10-
* `FnMut`: the closure captures by mutable reference (`&mut T`)
11-
* `FnOnce`: the closure captures by value (`T`)
10+
* `Fn`: the closure uses the captured value by reference (`&T`)
11+
* `FnMut`: the closure uses the captured value by mutable reference (`&mut T`)
12+
* `FnOnce`: the closure uses the captured value by value (`T`)
1213

1314
On a variable-by-variable basis, the compiler will capture variables in the
1415
least restrictive manner possible.

0 commit comments

Comments
 (0)