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

Generic parameters in machine! macro states? #21

Open
antifuchs opened this issue Jan 22, 2020 · 0 comments
Open

Generic parameters in machine! macro states? #21

antifuchs opened this issue Jan 22, 2020 · 0 comments

Comments

@antifuchs
Copy link

antifuchs commented Jan 22, 2020

Hi, I'd like to pass a type parameter in the data contained inside states. Here's an example of what I hope to do:

pub struct State<M> {
    pids: Vec<Pid>,
    config: WorkerConfig,
    phantom: PhantomData<M>,
}

machine! {
    #[derive(Clone, Debug, PartialEq)]
    pub enum WorkerSet<M> {
        Startup { state: State<M> },  // This currently complains.
        Running { state: State<M> }, // same.
    }
}

I feel the code above is natural seems right. Unfortunately, it looks like the code for the struct representations in each state enum variant end up without the type parameter and so I can't parameterize that type /:

Is there a workaround for this, or am I out of luck?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant