What is the right way of achieving Inheritance in rust

There is no right way to do inheritance in Rust.
That said, you can write code that does pretty much the same thing.

enum A {
      B(B),
      C(C),
}

struct B { ... }
struct C { ... }

impl A {
     fn setup(&self) {
            match self {
                  A::B(b) => { .... },
                  A::C(c) => { .... },
             }
      }
}
2 Likes