Rust Cheat Sheet

Home

Functions

Syntax

          fn <name of function>() {}
        

Function with Parameters

          fn <name of function>(<name of parameter>: Type, ...) {}
        

Call a function without passing it any arguments

          <name of function>();
        

Calling a function by passing an argument

          <name of function>(<name of argument>);
        

Note:

  • note the semicolon at the end (only when Calling a function).
  • The syntax <name of ...> refers to the name given to the element,
    which is written without angles.