Skip to content

Commit fde4c1e

Browse files
committed
Document what the type of the main() function should be
1 parent d7ae9f1 commit fde4c1e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

doc/rust.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,9 @@ location of which -- in the module tree of the current crate -- is defined
550550
from outside the source file: either by an explicit `source_directive` in
551551
a referencing crate file, or by the filename of the source file itself.
552552

553+
A source file that contains a `main` function can be compiled to an
554+
executable. If a `main` function is present, it must have no [type parameters](#type-parameters)
555+
and no [constraints](#constraints). Its return type must be [`nil`](#primitive-types) and it must either have no arguments, or a single argument of type `[str]`.
553556

554557
# Items and attributes
555558

@@ -592,6 +595,8 @@ the name of the enclosing item, or is private to the enclosing item (in the
592595
case of functions). The exact locations in which sub-items may be declared is
593596
given by the grammar.
594597

598+
### Type Parameters
599+
595600
All items except modules may be *parametrized* by type. Type parameters are
596601
given as a comma-separated list of identifiers enclosed in angle brackets
597602
(`<...>`), after the name of the item and before its definition. The type

0 commit comments

Comments
 (0)