...

/

Solution: Make Cats Meow and Dogs Bark

Solution: Make Cats Meow and Dogs Bark

Let's have a look at the solution to making cats meow and dogs bark.

We'll cover the following...

Solution

The complete solution to the problem is provided below. Let’s have a look at it.

Press + to interact
#[derive(PartialEq)]
enum AnimalType { Cat, Dog }
fn main() {
let animals = vec![ AnimalType::Cat, AnimalType::Dog ];
for animal in animals {
if animal == AnimalType::Cat {
println!("Meow");
}
else if animal == AnimalType::Dog {
println!("Woof");
}
else
{
println!("Not an animal");
}
}
}

Explanation

...