Hello everyone!
I am doing Rustlings, such a nice bedtime occupation .
I have a question about functions4.rs. The error is that sale_price has no return value, but I was certain that it was that is even took ownership of the variable price? Why is it not taking ownership and consuming at line
num % 2 == 0
?
fn main() {
let original_price = 51;
println!("Your sale price is {}", sale_price(original_price));
}
fn sale_price(price: i32) {
if is_even(price) {
price - 10
} else {
price - 3
}
}
fn is_even(num: i32) -> bool {
num % 2 == 0
}
Thank you, I saw that .
The first thing I thought about was that price was sent as "num" into the even function and should be consummed there.
What I am wondering is why is even does not consume price?