3 ms·
You can read up here: http://doc.rust-lang.org/book/generics.html http://doc.rust-lang.org/book/generics.html, as well about "output" generics here: https://git
by nercury 12y ago
You can read up here: http://doc.rust-lang.org/book/generics.html http://doc.rust-lang.org/book/generics.html, as well about "output" generics here: https://github.com/rust-lang/rfcs/blob/master/text/0195-associated-items.md https://github.com/rust-lang/rfcs/blob/master/text/0195-asso..., and explore usage in collections here: http://doc.rust-lang.org/nightly/std/collections/ http://doc.rust-lang.org/nightly/std/collections/.
- 12423gsd 12y agoAre "Traits" basically C++ Concepts?
- steveklabnik 12y agoThere are some technical details that make them different, if I recall correctly. But they're kinda similar. They're also close to Haskell's typeclasses.
- nercury 12y agoFor someone who knows C#, I would explain them as abstract extension methods that can be overriden for specific types.
- adrusi 12y agoSomewhere between C++ concepts and Haskell typeclasses with a hint of Java interfaces. But yes, their primary usage is to require that type parameters exhibit a certain set of properties.
- bjz_ 12y agoThey fill the same role as concepts - ie. bringing type checking to the call site when using parametrized types, rather than using a duck typed approach, which leads to the big template stack traces that you get in C++.