Skip to main content

Crate bitflags

Crate bitflags 

Source
Expand description

A verified subset of bitflags 2.13.0.

bitflags! forwards derives and layout attributes to the flags type. The flags type can derive traits such as Clone, Copy, Default, PartialEq, Eq, and Debug.

pub struct Flags(InternalFlags); // backing storage is private
impl Flags {
    pub const A: Self;   // one associated constant per declared flag
    ...
    pub const fn empty() -> Self;
    pub const fn all() -> Self;
    pub const fn bits(&self) -> T;
    pub const fn from_bits(bits: T) -> Option<Self>;
    pub const fn from_bits_truncate(bits: T) -> Self;
    pub const fn is_empty(&self) -> bool;
    pub const fn is_all(&self) -> bool;
    pub const fn contains(&self, other: Self) -> bool;
    pub const fn intersects(&self, other: Self) -> bool;
    pub fn insert(&mut self, other: Self);
    pub fn remove(&mut self, other: Self);
    pub fn toggle(&mut self, other: Self);
    pub fn set(&mut self, other: Self, value: bool);
}

Each executable constant has a closed spec constant and verified contracts, so callers can reason about its bits while the backing field stays private.

Verus-only specs and lemmas model flag metadata for the inherent APIs.

Re-exports§

pub use paste;

Macros§

bitflags
A macro wrapper for quickly defining bitflags with verified properties in Verus. Flag values are inferred in the declared backing integer type.

Structs§

Flags

Enums§

__ghostFlags