4 ms·
> current level of documentation they are in the realm of some obscure hacks I don't think so. Rust encourages a certain style of designing code, using enums a
by Manishearth 11y ago
> current level of documentation they are in the realm of some obscure hacks
I don't think so. Rust encourages a certain style of designing code, using enums and traits. Almost all the time this suffices.
My comment was at the macro level; I'm not saying that an OOP pattern will have an equivalent in Rust, I'm saying that if you look at the larger use case you can design your code in idiomatic Rust to avoid it.
- shmerl 11y ago> I'm saying that if you look at the larger use case you can design your code in idiomatic Rust to avoid it. As I said, may be you can, but it's far from trivial and unless you know how to do it already, coming up with such approaches isn't something that one who just learns the language would be focusing on. You yourself said above, that it's hard. And unlike languages like C++ where OOP approaches are very well documented, Rust documentation lacks such kind of information at present.
- Manishearth 11y ago> You yourself said above, that it's hard. I said modeling single inheritance is hard. That's a very niche use case; basically only crops up when writing an interpreter for a language with single inheritance (and in cases like Servo's DOM) > unless you know how to do it already, coming up with such approaches isn't something that one who just learns the language would be focusing on Again, it's not a thing that you do as a drop-in for inheritance. I'm saying that the regular approach (i.e. using traits and enums idiomatically) to designing your application in Rust will cover the use cases for inheritance, differently. Basically, don't try to write Rust code as if it's C++ or Java and stuff should work out.
- shmerl 11y agoI don't mean one has to copy ideas from C++ or Java to Rust verbatim, but having some explanation on how to use Rust OOP abstractions for solving common programming problems would be useful. I don't think current Rust documentation covers that well.
- Manishearth 11y agoAh, fair.