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...
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
Rust 1.40.0
#[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");}}}