Bitflags in Rust
Representing QFlags in Rust
Ayush Singh published on
4 min, 696 words
Background
While working on Rust bindings for KConfig as a part of Season of KDE 2022, I came across a few problems while trying to represent QFlags
in Rust:
- Most
QFlags
are defined as C++ enums in which multiple members can have the same value. This is not possible in Rust enum. - It is possible to enable multiple flags using BitwiseOr. Rust enums cannot do bitwise operations.