3 ms·
In the traits example > which tells the compiler “I just want something that implements Meow”. The ‘trait Meower’ also implies same, right? If so, why can’t w
by avinassh 4y ago
In the traits example
> which tells the compiler “I just want something that implements Meow”.
The ‘trait Meower’ also implies same, right? If so, why can’t we use that
- LegionMammal978 4y ago"trait Meower" just declares the trait. "impl Meower" tells the compiler to accept any type that implements the trait. It's the same as adding a generic parameter "<M: Meower>" and using "M", as with the example above that one. (Except in the second example it's placed behind a shared reference; it still works either way with either syntax.)