|
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, a set of parameters, and an output type. |
| 45 | +A _function_ consists of a [block] (that's the _body_ of the function), |
| 46 | +along with a name, a set of parameters, and an output type. |
46 | 47 | Other than a name, all these are optional.
|
47 | 48 | Functions are declared with the keyword `fn`.
|
48 | 49 | 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.
|
@@ -79,8 +80,8 @@ parameter may have an optional identifier, such as `args: ...`.
|
79 | 80 |
|
80 | 81 | ## Function body
|
81 | 82 |
|
82 |
| -The block of a function is conceptually wrapped in a block that binds the |
83 |
| -argument patterns and then `return`s the value of the function's block. This |
| 83 | +The body block of a function is conceptually wrapped in another block that first binds the |
| 84 | +argument patterns and then `return`s the value of the function's body. This |
84 | 85 | means that the tail expression of the block, if evaluated, ends up being
|
85 | 86 | returned to the caller. As usual, an explicit return expression within
|
86 | 87 | the body of the function will short-cut that implicit return, if reached.
|
@@ -325,7 +326,7 @@ responsibility to ensure that.
|
325 | 326 | ## Attributes on functions
|
326 | 327 |
|
327 | 328 | [Outer attributes][attributes] are allowed on functions. [Inner
|
328 |
| -attributes][attributes] are allowed directly after the `{` inside its [block]. |
| 329 | +attributes][attributes] are allowed directly after the `{` inside its body [block]. |
329 | 330 |
|
330 | 331 | This example shows an inner attribute on a function. The function is documented
|
331 | 332 | with just the word "Example".
|
|
0 commit comments