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

Missing None definition #53

Open
fuine opened this issue Nov 6, 2016 · 5 comments
Open

Missing None definition #53

fuine opened this issue Nov 6, 2016 · 5 comments

Comments

@fuine
Copy link

fuine commented Nov 6, 2016

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 ?

@ghost
Copy link

ghost commented Nov 6, 2016

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).

@fuine
Copy link
Author

fuine commented Nov 7, 2016

Ah ok, thanks. I guess i will stick to the 0.

@fuine fuine closed this as completed Nov 7, 2016
@ghost
Copy link

ghost commented Nov 27, 2016

Maybe I'll throw it back in when version 3 is ready. Glob imports are evil anyway.

@anko
Copy link

anko commented Jan 18, 2023

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.

@AltF02
Copy link
Owner

AltF02 commented Jan 18, 2023

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

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

No branches or pull requests

3 participants