Rust TutorialLesson 17Free preview
Rust Functions
This lesson is part of Rust · All levels
Summary
This lesson reviews the creation of custom functions, the acceptance of parameters, and the return of values in Rust. The function is declared with 'fn' and uses the snake_case convention. The reader will also understand the fundamental difference between a statement and an expression within a function body.
Key points
- The function is declared with the keyword 'fn' and the name is in the form of a snake_case
- The data type of each mandatory parameter is explicitly stated
- The return value type is written after the slender arrow '->'
- An expression without semicolon on the last line automatically becomes the return value of the function
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.