# Loop ## Example Execute the following command to run [`./solutions/examples/loop.rs`](https://github.com/Cyfrin/rust-crash-course/blob/main/topics/for_loop/solutions/examples/loop.rs) ```shell cargo run --example loop ``` ## Exercises Exercises are in [`./exercises/src/lib.rs`](https://github.com/Cyfrin/rust-crash-course/blob/main/topics/for_loop/exercises/src/lib.rs) ### Exercise 1 ```rust pub fn sum(nums: Vec<i32>) -> i32 { todo!(); } ``` Return the sum of all integers in the `nums` vector. ### Exercise 2 ```rust pub fn fill(i: u32, n: usize) -> Vec<u32> { todo!(); } ``` Return a vector of length `n`, filled with the value `i`. ## Test ```shell cargo test ```
Execute the following command to run ./solutions/examples/loop.rs
Exercises are in ./exercises/src/lib.rs
Return the sum of all integers in the nums vector.
Return a vector of length n, filled with the value i.
A foundational exploration of Loop - Build core programming skills by tackling exercises on finding minimums, maximums, and determining the sign of integers. You'll use conditional logic to implement these fundamental operations, preparing you for more complex iterative algorithms.
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