Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Rust: Functions

Status: Courses Tags: Rust

  1. Functions are defined like this below

    #![allow(unused)]
    fn main() {
    // Simple increment function
    fn function1(val: i32) -> i32 {
      newval = val + 1;
    }
    // Function with mutable arguments
    fn function1( mut val: i32) -> i32 {
      val = val + 1;
    }
    }