Skip to content

Commit 42dc534

Browse files
committed
functions.md: state that the default return type is the unit type
1 parent 3c30c79 commit 42dc534

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/items/functions.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@
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.
45+
A _function_ consists of a [block], along with a name, a set of parameters, and an output type.
4646
Other than a name, all these are optional.
4747
Functions are declared with the keyword `fn`.
4848
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].
4950

5051
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.
5152

@@ -387,6 +388,7 @@ fn foo_oof(#[some_inert_attribute] arg: u8) {
387388
[block]: ../expressions/block-expr.md
388389
[variables]: ../variables.md
389390
[type]: ../types.md#type-expressions
391+
[unit type]: ../types/tuple.md
390392
[*function item type*]: ../types/function-item.md
391393
[Trait]: traits.md
392394
[attributes]: ../attributes.md

0 commit comments

Comments
 (0)