File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 33While Rust chooses how to capture variables on the fly mostly without type
44annotation, this ambiguity is not allowed when writing functions. When
55taking 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,
78they 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
1314On a variable-by-variable basis, the compiler will capture variables in the
1415least restrictive manner possible.
You can’t perform that action at this time.
0 commit comments