1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-02-13 00:16:11 +02:00

Merge pull request #186 from rastringer/patch-1

Speaker notes for 6.5 Functions
This commit is contained in:
Martin Geisler 2023-01-19 14:48:11 +01:00 committed by GitHub
commit 790e964ee6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,3 +29,12 @@ fn fizzbuzz_to(n: u32) { // `-> ()` is normally omitted
}
}
```
<details>
* We refer in `main` to a function written below. Neither forward declarations nor headers are necessary.
* Declaration parameters are followed by a type (the reverse of some programming languages), then a return type.
* The last expression in a function body becomes the return value. Simply omit the `;` at the end of the expression.
* Some functions have no return value, and output the 'unit type', `()`. The compiler will infer this if the `-> ()` return type is omitted.
</details>