| ▲ | Surac 5 hours ago | |
As a non Rust man, how real are the problems in this article? Does it show up in real word or is it just a edge case? I only program in C17, C++ as C with classes and C#. Anyone can give me a good read what Traits even are? | ||
| ▲ | swiftcoder 3 hours ago | parent [-] | |
> As a non Rust man, how real are the problems in this article? Real, but of more concern to folks designing widely-used libraries than to folks using said libraries. > Anyone can give me a good read what Traits even are? You can think of traits as analogous to interfaces in OOP languages (i.e. pure virtual abstract classes in C++ terminology). They just define a set of methods that types can implement to conform to the trait, and then consumers can treat implementing types as if they were the trait. The major differences are: traits are implemented outside the actual type implementation, so arbitrary trait implementations can be added after the type has been written (this is why we need coherence), and rust uses traits as compile-time bounds for generics (templates). | ||