Skip to content

Platform-Specific Enum Variants #3064

@daxpedda

Description

@daxpedda

From #3056 (comment):

If we want to continue using the extension trait model for platform-specific features, I came up with the following idea that we could use for enums:

enum Event {
    EventA,
    EventB(String),
    EventC {
        data: u16,
    },
    Platform(PlatformEvent),
}

impl PlatformEventExtWayland for PlatformEvent {
    fn event(&self) -> WaylandEvent {
        self.0
    }
}

// Not really needed, just a neat idea.
impl PlatformEventExtWindows for PlatformEvent {
    fn event(&self) -> ! {
        match self.0 { }
    }
}

Alternatively we can always mark the enum #[non_exhausive] and add cfg-gated variants.


For consistency with the current API I would like to go with the first solution. The first thing I would like to apply this to is to re-introduce the ControlFlow enum after #3056.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions