x11-rs
x11-rs copied to clipboard
Missing None definition
I'm porting some code from C to Rust, and it is frequently using None to compare against Window or Atom. In the X11/X.h None is defined to be 0 by preprocessor macro. Currently i compare values against 0, but that doesn't seem like a good idea. What is the reason behind None not being in the API ?
None was in early versions, but when I was porting others' projects to use x11-rs, it was causing problems with glob imports, causing x11::None to override std::option::None. It is explicitly defined as zero in the X11 specs, so it's okay to compare to zero instead of None. The implementation will never change it to something crazy like ((XID)-1).
Ah ok, thanks. I guess i will stick to the 0.
Maybe I'll throw it back in when version 3 is ready. Glob imports are evil anyway.
I think the constant should exist. Name collision is unavoidable, and solved with crate namespacing.
Anyone who wants to annoy all future maintainers of their software with use x11::*; presumably knows what they're doing, and deserves the clear and helpful compiler errors they'll get.
As @dagit mentioned, I do think having maybe a XNone constant could be helpful. Possibly to be added to xlib.rs. Does require documentation. Which this library is currently completely missing. As the old old maintainer mentioned, possibly something for v3. Afaik he was planning to go for a similar approach as x11rb does atm