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

Use NonZeroU32 as the backing type for Keysym #13

Open
notgull opened this issue Jun 22, 2023 · 3 comments
Open

Use NonZeroU32 as the backing type for Keysym #13

notgull opened this issue Jun 22, 2023 · 3 comments

Comments

@notgull
Copy link
Member

notgull commented Jun 22, 2023

X11 generally uses the NO_KEYSYM value, as alias for zero, to denote that a keysym is not present. Therefore it would make sense to use a NonZeroU32 as the backing type for the Keysym type instead of u32. This way, for Option<Keysym> there is no ambiguity between None and Some(NO_KEYSYM).

Cons:

  • There may be a necessary difference between None and Some(NO_KEYSYM).
  • Requires raising the MSRV to 1.57 (although most of the windowing ecosystem is past that already so I wouldn't mind).
@kchibisov
Copy link
Member

The main issue is that passing around in FFI is a bit awkward for such a type.

@notgull
Copy link
Member Author

notgull commented Jun 22, 2023

I suppose. Although it would be safe to use as the input for a function, and Option<Keysym> is fully FFI safe.

@kchibisov
Copy link
Member

Ah, yes, that's true. Well, we could do so, I guess, but the thing is that not all crates do Option<Keysym> and I think you'd need to convert.

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

No branches or pull requests

2 participants