static av1_intra_prediction_edges
: Make non-mut
by replacing #[derive(BitfieldStruct)]
with bools_bitfield_struct!
for const fn
s
#497
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#[derive(c2rust_bitfields::BitfieldStruct)]
doesn't generateconst fn
s (immunant/c2rust#1027), so it can't be used in aconst
block to initialize astatic
. Thus, thestatic
has to mademut
andunsafe
and initialized at runtime.I opened immunant/c2rust#1027 and looked into making the generated
fn
sconst
, but they used a lot oftrait
s, which can't containconst fn
s, so it seemed like non-trivial work. I also tried looking for other off-the-shelf bitfield crates, but they all either didn't supportconst fn
s or still relied ontrait
s within them, and thus only could createconst fn
s withnightly
features.Thus, I rolled my own
macro_rules!
macro,bools_bitfield_struct!
that generatesconst fn
s. The macro is specific for bitfields that are alwaysbool
s, which makes things a bit simpler and have a cleaner API. And it also doesn't have to worry about being#[repr(C)]
at all, which might makes things a bit simpler, too. Overall, though, it's quite a simple macro, so it seemed much easier to do it this. Sincerav1d
only used bitfields here, I kept the macro private in this file, but if we ever need bitfields that are allbool
s elsewhere, we can extract the macro. Thec2rust-bitfields
dependency is also now removed as it's unused.