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:

  1. Most QFlags are defined as C++ enums in which multiple members can have the same value. This is not possible in Rust enum.
  2. It is possible to enable multiple flags using BitwiseOr. Rust enums cannot do bitwise operations.
Read More