Skip to content

Commit 044a6aa

Browse files
committed
A couple tweaks
1 parent 9953493 commit 044a6aa

File tree

6 files changed

+11
-7
lines changed

6 files changed

+11
-7
lines changed

examples/fn/closures/anonymity/anonymity.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// `F` must implement `Fn` for a function which takes no
1+
// `F` must implement `Fn` for a closure which takes no
22
// inputs and returns nothing. Exactly what is required
3-
// for `diary`.
3+
// for `print`.
44
fn apply<F>(f: F) where
55
F: Fn() {
66

examples/fn/closures/anonymity/input.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Closures are supposedly anonymous. Does that affect it's usage? It surely
2-
does. Observe how using a closure in a function requires generics, which
3-
is necessary because of how they are defined:
1+
Closures succinctly capture variables from enclosing scopes. Does this have
2+
any consequences? It surely does. Observe how using a closure in a function
3+
requires generics, which is necessary because of how they are defined:
44

55
```rust
66
// `F` must be generic.

examples/fn/closures/input.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ can capture the enclosing environment. Their syntax and capabilties make them
33
very convenient for on the fly usage. Some characteristics include:
44

55
* uses `||` instead of `()` around input variables.
6-
* *both* input and return types can be inferred.
6+
* *both* input and return *types* can be inferred.
7+
* input variable *names* must be specified.
78
* body delimination (`{}`) is optional for a single expression. Mandatory
89
otherwise.
910
* the outer environment variables *may* be captured.

examples/fn/closures/input_parameters/input_parameters.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ fn apply_to_3<F>(f: F) -> i32 where
1717

1818
fn main() {
1919
let greeting = "hello";
20+
// A non-copy type.
2021
let mut farewell = "goodbye".to_owned();
2122

2223
// Capture 2 variables: `greeting` by reference and

examples/fn/closures/output_parameters/output_parameters.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#![feature(core)]
22
use std::boxed::FnBox;
33

4+
// Return a closure taking no inputs and returning nothing
5+
// which implements `FnBox` (capture by value).
46
fn create_fnbox() -> Box<FnBox()> {
57
let text = "FnBox".to_owned();
68

examples/structure.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
{ "id": "closures", "title": "Closures", "children": [
6060
{ "id": "capture", "title": "Capturing", "children": null },
6161
{ "id": "input_parameters", "title": "As input parameters", "children": null },
62-
{ "id": "anonymity", "title": "Anonymity", "children": null },
62+
{ "id": "anonymity", "title": "Type anonymity", "children": null },
6363
{ "id": "input_functions", "title": "Input functions", "children": null },
6464
{ "id": "output_parameters", "title": "As output parameters", "children": null },
6565
{ "id": "closure_analysis", "title": "Analysis", "children": [

0 commit comments

Comments
 (0)