1

I come from Java/C# background and inheritance is an important concept in there, and it's such an important feature in so many use cases. Need to know, how to get around it in Rust.

I know, Rust doesn't support inheritance directly.

AmitSan
  • 25
  • 4
  • 2
    When you want OOP, then Rust is probably not the language that you should use. When watching [this](https://youtu.be/IRTfhkiAqPw), you may understand what I mean. – habrewning Jul 04 '23 at 05:21
  • 2
    Hello, i suggest you to read the following documentation, [Rust OOP](https://doc.rust-lang.org/book/ch17-00-oop.html). – Zeppi Jul 04 '23 at 05:25

1 Answers1

1

Rust is not an "OOP" language, however it has some features of OOP languages. Trying to write code that you would write in Java or C# in Rust will result in nothing, but confusion and suffering.

While in general Rust encourages to use composition over inheritance, you could you could use traits and super traits to express inheritance-like relation between interfaces (and not objects themselves).

Aleksander Krauze
  • 3,115
  • 7
  • 18