Skip to content

Merge all *State structs and GameState trait into one universal State struct #255

@ozkriff

Description

@ozkriff

Required for #253 and must greatly simplify codebase.

Right now I have InternalState, FullState, PartialState, TmpPartialState structs and GameState trait which is implemented for all of them. This greatly complicates #253 (see comments) because you need generalized code in some places and concrete struct in other places + it introduses a few lifetime-related problems with TmpPartialState.

So I want to try to merge all this into one universal State struct which can fill all these roles and will not have any lifetime parameters.

The only way to achieve this that I see is to use "option hack": have an for: Option<Fow> fields in the struct and insert/extract (using Option::take and movement semantics) it for switching between FullState/PartialState roles.

Demo: https://play.rust-lang.org/?gist=401412510e667a291c151b84b7be6a98

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions