I have a structure Game
and I want to be able to build an object but with the possibility to remove features at compile time, to optimize memory or processor cycles.
struct Game {
history: Vec<SomeType>,
}
impl Game {
fn new() {}
fn new_opti() {}
}
For example, in this structure the optimized version would have no history. Here, I replaced history
with an Option<Vec<SomeType>>
and in the optimized version I put a None
and I change the behavior of the history dependent methods, and I disable some methods.
I think this is a hacky way, but what would be a better way? There is no need to keep only one struct.