Skip to content

Commit

Permalink
Add example to README
Browse files Browse the repository at this point in the history
  • Loading branch information
Seelengrab committed Feb 25, 2024
1 parent abc676a commit cda6564
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,29 @@
[![codecov](https://codecov.io/github/Seelengrab/FieldFlags.jl/branch/main/graph/badge.svg?token=PBH8NJCHKS)](https://codecov.io/github/Seelengrab/FieldFlags.jl)

FieldFlags.jl is a small package for declaring [bitfield](https://en.wikipedia.org/wiki/Bit_field)-like structs, without
having to manually mask out bits. For more information, check out the [documentation](https://seelengrab.github.io/FieldFlags.jl/)!
having to manually mask out bits. For more information, check out the [documentation](https://seelengrab.github.io/FieldFlags.jl/)!

```julia-repl
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
```

0 comments on commit cda6564

Please sign in to comment.