January 2019
Beginner to intermediate
554 pages
13h 31m
English
Functions in Rust also have a concrete type and they differ in terms of their argument types and also in their arity, as in how many arguments they take, as in the example:
// function_types.rsfn add_two(a: u32, b: u32) -> u32 { a + b}fn main() { let my_func = add_two; let res = my_func(3, 4); println!("{:?}", res);}
Functions in Rust are first class citizens. This means they can be stored in variables or passed to other functions or returned from functions. The preceding code declares a function add_two, which we store in my_func and later invoke with 3 and 4.
Read now
Unlock full access