Let's talk about functions. You've seen the main function quite a bit already. Let's talk about functions. In general functions are defined using the fun keyword. fn is pronounced fun. The rust style guide says to use snake case for function names, lowercase words separated by underscores.
One awesome thing about rust is that functions don't have to appear in the file before code that calls them. So feel free to leave main at the top of your main.rs file if you like Hooray. For more chronologically arranged source code systems programmers can have nice things to function parameters are always defined with name colon type, and of course multiple parameters are separated by a comma. You specify the return type after the parameters by adding an arrow pointing to the return type, the arrow is a hyphen and then a greater than symbol and the body of the function is inside a block. You can return a value from a function using the returns keyword as you would expect, there's also a shorthand for returning values. If you leave the semi colon off of the last expression in a block, then it will be returned as the value of the block.
This is called a tail expression. In other words, this is the same as this whenever you are returning something at the end of the block the shorter ways preferred in idiomatic rust. calling a function looks the same as in most of the languages. there's currently no support for named arguments at the call site, so you need to provide all the values in the correct order. Finally, a single rust function does not support variable numbers of arguments or different types for the same argument. But macros such as print line do a macro call looks just like a function call except the name of a macro always ends with an exclamation mark.
We will use a couple common macros but I won't be teaching you how to create them anytime soon. That's a more advanced topic. In the next video, we'll go over the module system