|
42 | 42 | > [^fn-param-2015]: Function parameters with only a type are only allowed |
43 | 43 | > in an associated function of a [trait item] in the 2015 edition. |
44 | 44 |
|
45 | | -A _function_ consists of a [block], along with a name and a set of parameters. |
46 | | -Other than a name, all these are optional. Functions are declared with the |
47 | | -keyword `fn`. Functions may declare a set of *input* [*variables*][variables] |
48 | | -as parameters, through which the caller passes arguments into the function, and |
49 | | -the *output* [*type*][type] of the value the function will return to its caller |
50 | | -on completion. |
| 45 | +A _function_ consists of a [block], along with a name, a set of parameters, and an output type. |
| 46 | +Other than a name, all these are optional. |
| 47 | +Functions are declared with the keyword `fn`. |
| 48 | +Functions may declare a set of *input* [*variables*][variables] as parameters, through which the caller passes arguments into the function, and the *output* [*type*][type] of the value the function will return to its caller on completion. |
| 49 | +If the output type is not explicitly stated, it is the [unit type]. |
51 | 50 |
|
52 | | -When referred to, a _function_ yields a first-class *value* of the |
53 | | -corresponding zero-sized [*function item type*], which |
54 | | -when called evaluates to a direct call to the function. |
| 51 | +When referred to, a _function_ yields a first-class *value* of the corresponding zero-sized [*function item type*], which when called evaluates to a direct call to the function. |
55 | 52 |
|
56 | 53 | For example, this is a simple function: |
57 | 54 | ```rust |
@@ -391,6 +388,7 @@ fn foo_oof(#[some_inert_attribute] arg: u8) { |
391 | 388 | [block]: ../expressions/block-expr.md |
392 | 389 | [variables]: ../variables.md |
393 | 390 | [type]: ../types.md#type-expressions |
| 391 | +[unit type]: ../types/tuple.md |
394 | 392 | [*function item type*]: ../types/function-item.md |
395 | 393 | [Trait]: traits.md |
396 | 394 | [attributes]: ../attributes.md |
|
0 commit comments