# Function ## Example Execute the following command to run [`./solutions/examples/func.rs`](https://github.com/Cyfrin/rust-crash-course/blob/main/topics/function/solutions/examples/func.rs) ```shell cargo run --example func ``` ## Exercises Exercises are in [`./exercises/src/lib.rs`](https://github.com/Cyfrin/rust-crash-course/blob/main/topics/function/exercises/src/lib.rs) ### Exercise 1 ```rust pub fn mul() { todo!(); } ``` Fix the function `mul` inside [`./exercises/src/lib.rs`](https://github.com/Cyfrin/rust-crash-course/blob/main/topics/function/exercises/src/lib.rs) This the function should take 2 inputs of the type `u32`, multiply them and then return the product. ### Exercise 2 ```rust pub fn div() { todo!(); } ``` Fix the function `div` inside [`./exercises/src/lib.rs`](https://github.com/Cyfrin/rust-crash-course/blob/main/topics/function/exercises/src/lib.rs) This the function should take 2 inputs of the type `u32`, divide them and then return the quotient. ## Test ```shell cargo test ```
Execute the following command to run ./solutions/examples/func.rs
Exercises are in ./exercises/src/lib.rs
Fix the function mul inside ./exercises/src/lib.rs
This the function should take 2 inputs of the type u32, multiply them and then return the product.
Fix the function div inside ./exercises/src/lib.rs
This the function should take 2 inputs of the type u32, divide them and then return the quotient.
A hands-on exploration of Function - Understand how to define and utilize functions in Rust, including specifying parameters and return types. You'll apply this by implementing `mul` and `div` functions, which take two `u32` inputs and return their product and quotient respectively.
Course Overview
About the course
Introduction to the Rust programming language
Rust variables and functions
Scalar types, arrays, strings, enum, structs, vectors, and hash maps in Rust
Rust control flows: If / else, if let and let else, loop, match
Rust ownership, including borrow and references
Rust error handling
Rust Modules
Rust Traits
Last updated on November 7, 2025
Rust Developer
Rust Programming BasicsCourse Overview
About the course
Introduction to the Rust programming language
Rust variables and functions
Scalar types, arrays, strings, enum, structs, vectors, and hash maps in Rust
Rust control flows: If / else, if let and let else, loop, match
Rust ownership, including borrow and references
Rust error handling
Rust Modules
Rust Traits
Last updated on November 7, 2025