Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Ergonomic State definition #106

Open
azriel91 opened this issue Mar 12, 2020 · 0 comments
Open

Refactor: Ergonomic State definition #106

azriel91 opened this issue Mar 12, 2020 · 0 comments
Labels
M: code Code maintenance and quality.
Milestone

Comments

@azriel91
Copy link
Owner

In GitLab by @azriel91 on Mar 26, 2019, 15:22

Currently impl State for MyState is written as:

  • For states that are not aliases to AppState:

    impl<'a, 'b, S> State<GameData<'a, 'b>, AppEvent> for LoadingState<'a, 'b, S>
  • For states that are aliases to AppState:

    pub type CharacterSelectionState<'a, 'b, F, S> =
        AppState<'a, 'b, CharacterSelectionStateDelegate<'a, 'b, F, S>, CharacterSelectionEntityId>;
    
    impl<'a, 'b, F, S> State<GameData<'a, 'b>, AppEvent>
        for CharacterSelectionStateDelegate<'a, 'b, F, S>

This is very verbose. Also, we have this:

pub trait AutexState<'a, 'b>: State<GameData<'a, 'b>, AppEvent> {}

// Blanket impl.
impl<'a, 'b, T> AutexState<'a, 'b> for T where T: State<GameData<'a, 'b>, AppEvent> {}

To make it ergonomic to implement states, it would be much better if that could change to:

impl<S> State for LoadingState<S>

This possibly means all states having the behaviour of the current AppState.

@azriel91 azriel91 added the M: code Code maintenance and quality. label Mar 12, 2020
@azriel91 azriel91 added this to the Backlog milestone Mar 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M: code Code maintenance and quality.
Projects
None yet
Development

No branches or pull requests

1 participant