News for hackers. Stuff that matters.
Re:Abstraction without overhead: traits in Rust by skybrian on Monday May 11, 2015 @03:11PM (#9527157)
This is also how Go does it. It looks like Rust traits can do everything Go interfaces can do, and more?
Re:Abstraction without overhead: traits in Rust by pcwalton on Monday May 11, 2015 @03:29PM (#9527261)
More or less, yeah. The main missing features are that downcasting isn't implemented at present (since Rust's other features remove the need for most of it), and implementation is explicit instead of implicit (a design decision which I've elaborated on in the past).
Re:Abstraction without overhead: traits in Rust by keeperofdakeys on Monday May 11, 2015 @07:10PM (#9528457)
There are some key differences, like Rust traits using generics, and Go interfaces using an empty interface for generic code.
Re:Abstraction without overhead: traits in Rust by Manishearth on Tuesday May 12, 2015 @06:08AM (#9530588)
Go's interfaces have these additional features:

- They auto-implement on types that have the appropriate methods (a feature that probably is unwanted in Rust) - They can be runtime downcasted via `.(type_name_here)` - They can be runtime type switched via `switch foo.(type)`

I'm not sure of the vtable internals though.