Skip to content

Commit

Permalink
Use bitfield-struct crate for PackedOperation.
Browse files Browse the repository at this point in the history
Trying out a neat crate for Rust bitfields. The caveats are:

* Custom enums used in the bitfield must specify const funcs for bit
  conversion, and bytemuck's cast functions aren't const.
* The bitfield crate implements Clone for you, but does not seem to have
  a way to disable this. We can't rely on their clone, since for pointer
  types we need to allocate a new Box. To get around this,
  PackedOperation is a wrapper around an internal bitfield struct
  (rather than being a bitfield struct itself).

(Note: I'm not yet happy with this. Specifically, I think the
abstraction may be cleaner if OpBitField is defined entirely in terms of
raw native types and any reinterpretation / transmutation is done from
PackedOperation. Consider this a first pass.)
  • Loading branch information
kevinhartman committed Dec 9, 2024
1 parent 8b031c2 commit 9ef2443
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 103 deletions.
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ license = "Apache-2.0"
# Each crate can add on specific features freely as it inherits.
[workspace.dependencies]
bytemuck = "1.19"
bitfield-struct = "0.9.3"
indexmap.version = "2.6.0"
hashbrown.version = "0.14.5"
num-bigint = "0.4"
Expand Down
1 change: 1 addition & 0 deletions crates/circuit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ rayon.workspace = true
ahash.workspace = true
rustworkx-core.workspace = true
bytemuck.workspace = true
bitfield-struct.workspace = true
num-complex.workspace = true
ndarray.workspace = true
numpy.workspace = true
Expand Down
Loading

0 comments on commit 9ef2443

Please sign in to comment.