From the course: Rust Essential Training
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Function parameters - Rust Tutorial
From the course: Rust Essential Training
Function parameters
- [Instructor] Functions allow us to organize related sections of code into reusable modules that can be easily called again to execute from elsewhere. It's rare to encounter a program that doesn't use functions. In fact, every rest program has at least one function. The main function, which serves as the entry point to begin execution. We can declare additional functions by using the fn keyword, followed by a unique function name which is typically written using lowercase letters and underscores. After that we have opening close parentheses and then a pair of opening close curly braces. Since I named this function say hello let's make it say hello with a print macro. Now that we've defined our new function, we can call it from within our main program, by using the function name followed by a pair of parentheses. Notice that we've defined the say hello function after the main function, which is where it gets called. Unlike…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.