File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
content/lessons/06_closures_iterators Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -30,8 +30,6 @@ Closures can capture variables from the environment where they are defined. They
30
30
** HOW** closures capture variables is one thing.
31
31
But even more important is ** WHAT** closures do with their captures.
32
32
33
- {{ include_code_sample(path="lessons/06_closures_iterators/closures_capturing.rs", language="rust") }}
34
-
35
33
### Functions & closures hierarchy
36
34
37
35
Based on ** WHAT** a closure does with its captures, it implements closure traits:
@@ -44,9 +42,13 @@ For completeness, there is a (concrete) type of function pointers:
44
42
45
43
- ` fn ` - functions, closures with no captures.
46
44
47
- Those traits and the ` fn ` type form a hierarchy: ` fn ` < ` Fn ` < ` FnMut ` < ` FnOnce `
45
+ Those traits and the ` fn ` type form a hierarchy: ` fn ` ⊆ ` Fn ` ⊆ ` FnMut ` ⊆ ` FnOnce `
46
+
47
+ <!-- > $$ fn \subseteq Fn \subseteq FnMut \subseteq FnOnce $$ -->
48
48
49
- $$ fn \subseteq Fn \subseteq FnMut \subseteq FnOnce $$
49
+ The following code sample demonstrates various ways to capture environment (borrowing or moving) and various
50
+
51
+ {{ include_code_sample(path="lessons/06_closures_iterators/closures_capturing.rs", language="rust") }}
50
52
51
53
## Examples
52
54
You can’t perform that action at this time.
0 commit comments