Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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



"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.)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: