...

/

Call Another Function

Call Another Function

We'll cover the following...

This lesson is going to continue building on the code from the last lesson. You should keep coming back to this code block and continuing the edits.

Press + to interact
struct Fruit {
apples: i32,
bananas: i32,
}
fn count_fruit(fruit: Fruit) {
println!(
"I've got {} apples and {} bananas",
fruit.apples, fruit.bananas
);
}
fn main() {
let fruit = Fruit {
apples: 10,
bananas: 5,
};
count_fruit(fruit);
}

Now it’s time to define our price_fruit function. For the moment, comment out the count_fruit function call in main by putting // in front of it. Then add the ...