FieldFlags.jl

A small package for creating bitfield-like structs.
Author Seelengrab
Popularity
11 Stars
Updated Last
2 Months Ago
Started In
March 2023

FieldFlags.jl

CI Stable CI Nightly docs-stable docs-dev codecov

FieldFlags.jl is a small package for declaring bitfield-like structs, without having to manually mask out bits. For more information, check out the documentation!

julia> using FieldFlags

julia> @bitfield mutable struct Foo
           a:1
           b:2
           _:7
           c:3
       end

# The type only takes up 2 bytes
julia> sizeof(Foo)
2

julia> f = Foo(1,2,3)
Foo(a: true, b: 0x2, c: 0x3)

julia> f.a = 2
2

# Assignments truncate leading bits!
julia> f.a
false

Required Packages

No packages found.