Barbacamanitu

joined 1 year ago
[–] Barbacamanitu@lemmy.world 1 points 1 year ago

Yeah, you can't pass one type when the function expects another type. You have either use generics and trait bounds or provide the exact type that a function expects..

[–] Barbacamanitu@lemmy.world 1 points 1 year ago

Yeah, you can't pass one type when the function expects another type. You have either use generics and trait bounds or provide the exact type that a function expects..

[–] Barbacamanitu@lemmy.world 5 points 1 year ago (3 children)

What errors are you getting when converting from BaseArmy to Army? If you're storing references to other structs in your struct, things can get complicated. Using Clone/Copy types will make things easier.

I'd also recommend the builder pattern for this. It let's you build up a type incrementally, with a final build step that produces the final type.