| ▲ | layer8 4 hours ago | |||||||
Rust doesn’t have implementation inheritance. If it did, it would need some constructor-like concept as well to enforce encapsulation between inherited implementation and inheriting implementation. | ||||||||
| ▲ | aw1621107 3 hours ago | parent | next [-] | |||||||
Even if you assume that's true that seems more like "constructors are needed for implementation inheritance" than "constructors are needed for RAII". I'm not even sure about the former? The important bit is that base class invariants can't be observed in an invalid/inconsistent state, and regular visibility/privacy/etc. rules seem technically sufficient for that? I'm not sure where exactly the boundaries of "constructor-like concept" are supposed to lie. | ||||||||
| ▲ | ninkendo 4 hours ago | parent | prev [-] | |||||||
Objective-C has implementation inheritance but doesn't have constructors, I don't think constructors are essential there. As I said in the OP, `Cow::new()` can easily just call `Animal::new()` before continuing to initialize its own fields, etc. Heck, Smalltalk is the original OOP language and has implementation-based inheritance, and construction is done through ordinary methods on class objects. | ||||||||
| ||||||||