Need Assistance?

support@tutorialshub.in

Functions & Control Flow

Functions, Statements vs Expressions

ADVERTISEMENT
Rust Free Lesson
5 min read
ADVERTISEMENT

In Rust, function parameters always require explicit type annotations. Even better: Rust is an expression-based language. The final line of a function without a semicolon automatically becomes its return value!

Adding a semicolon turns an expression into a statement (returning () unit), so leave off the semicolon on the last line when returning a value.

ADVERTISEMENT
Hi, I'm Tuby! Here to help you