madsmtm / objc2

Bindings to Apple's frameworks in Rust
https://docs.rs/objc2/
MIT License
280 stars 35 forks source link

Implement `bitflags!`-like traits for `NS_OPTIONS` enums #602

Closed madsmtm closed 11 hours ago

madsmtm commented 1 month ago

These are quite annoying to work with without the core::ops::Bit* operators implemented.

Part of https://github.com/madsmtm/objc2/issues/310.

madsmtm commented 2 weeks ago

I think it makes sense to use bitflags directly, as it also exposes the Flags type, which is useful for users.

Though a bit unsure of how it should be implemented?

Maybe it's okay to force a dependency on it whenever a file uses NS_OPTIONS? Or maybe we should only cfg-gate the consts, so that the type itself is always available? Cfg-gating the implementations provided by bitflags! might be confusing, as in basically all cases where you want to use a NS_OPTIONS, you want the bitflags capabilities as well.