rust-by-practice
rust-by-practice copied to clipboard
fix: provide solution that satisfies requirement
The specification says we have to return something that implements Animal, but can't tell which at compile time. The existing solution only returns one concrete type Sheep, while the intent was to return either Sheep or Cow. This requires type erasure that can only be done with a reference to dyn trait.
After reviewing the surrounding text it's clear this isn't the right solution, but then the exercise asks for something that can't be done: use impl Trait
to return values for which the type can't be determined at compile time.