Return different implementations based on configuration

Would it look like that with using the phantomdata?

If you need to pass a value as an argument, then that's one way to do it.

Can you explain why it needs a value? I think most Rustaceans would prefer a type parameter.

This is for a prototype of an API SDK where the API provider has multiple API's with different URL's. I want the main struct to have some fields that should be present in A,B, while A, B may have their own unique fields. It is kind of like inheritance. I don't come from Rust.

For example: A and B have different base urls

but main Wrapper has a reqwest client for both.

I see. The Book has a chapter on OOP patterns in Rust: Object Oriented Programming Features of Rust - The Rust Programming Language

My recommendation is don't go against the grain.

thank you, and yes I would prefer writing idiomatic rust =)

So implementing default would be a start?


enum Kind {
    A,
    B,
    C,
}

impl Default for Kind {
    fn default() -> Self { Kind::A }
}