Skip to content

storing an interface in a generic type, like ArrayList? #3

Description

@emperor-limitless

so I was planning to use this for a stack based state machine thing, which requires me to have an ArrrayList or the equivilant, however, if I do

const std = @import("std");
const interface = @import("interface").Interface;

const State = interface(.{
    .onEnter = fn(anytype),
    // ...
});

const StateManager = struct {
    stack: ArrayList(anytype), // error.
}

so I'm wondering how can I store instances of struct? Note, it's not limited to one implementation, I could have a MenuState, A Gameplay state, etc, so having it store anything that implements the State interface is necessary

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions