Exercises

Exercise 1

The is_five function below has a bug. You can fix it by either adding in a borrow (&) or deref (*). Try fixing it both ways.

Press + to interact
fn is_five(x: &i32) -> bool {
x == 5
}
fn main() {
assert!(is_five(&5));
assert!(!is_five(&6));
println!("Success!");
}

Exercise 2

Fix the call to the add function inside ...

Access this course and 1400+ top-rated courses and projects.