3 ms·
I don't see how traits are limited. Traits are types, though you need to put them behind a pointer (Box<Trait> or &Trait) if you want to use them as types; and
by Manishearth 11y ago
I don't see how traits are limited.
Traits are types, though you need to put them behind a pointer (Box<Trait> or &Trait) if you want to use them as types; and this is dynamic dispatch.
You can use them in static dispatch (generics) too, and in general you should try to do that whenever possible. Plus there are loads of things you can do with them that Go can't (static trait methods, associated items, generics, etc)
The only feature that Go interfaces have that Rust traits don't is auto-implementation, and that's a misfeature IMO. It works okay for Go, but in Rust it makes more sense to explicitly say that you are implementing a trait.
- deleted 11y ago[deleted]