Skip to content

Generic parameters in machine! macro states? #21

@antifuchs

Description

@antifuchs

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions