Skip to content

Commit d3da60e

Browse files
authored
Merge pull request #1199 from mattheww/2022-05_return_types
Say that that the default function return type is the unit type
2 parents d029b86 + 42dc534 commit d3da60e

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/items/functions.md

+7-9
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,13 @@
4242
> [^fn-param-2015]: Function parameters with only a type are only allowed
4343
> in an associated function of a [trait item] in the 2015 edition.
4444
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].
5150

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.
5552

5653
For example, this is a simple function:
5754
```rust
@@ -391,6 +388,7 @@ fn foo_oof(#[some_inert_attribute] arg: u8) {
391388
[block]: ../expressions/block-expr.md
392389
[variables]: ../variables.md
393390
[type]: ../types.md#type-expressions
391+
[unit type]: ../types/tuple.md
394392
[*function item type*]: ../types/function-item.md
395393
[Trait]: traits.md
396394
[attributes]: ../attributes.md

0 commit comments

Comments
 (0)