rust-windowing / rust-windowing/winit
Platform-Specific Enum Variants
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 6.2k
- Forks
- 1.3k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 9
Description
From https://github.com/rust-windowing/winit/pull/3056#issuecomment-1695542094:
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the discussion in PR #3056 and the current API around ControlFlow. Define how the proposed platform-specific enum extension model should reintroduce ControlFlow consistently across platforms; done means the API design is agreed and the implementation covers the relevant platform variants.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- desktop
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100