rust-windowing / xkeysym

X11 keyboard symbol utilities for Rust
Apache License 2.0
9 stars 5 forks source link

Use NonZeroU32 as the backing type for Keysym #13

Open notgull opened 1 year ago

notgull commented 1 year ago

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:

kchibisov commented 1 year ago

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

notgull commented 1 year ago

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

kchibisov commented 1 year ago

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.