Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ALL_FLAGS length instead of manually set associated constant #1684

Merged

Conversation

thibault-martinez
Copy link
Member

@thibault-martinez thibault-martinez commented Nov 26, 2023

The constant needs to be set manually and is very easily out of sync (as currently is), potentially making random tests to fail. Instead we can use *Flags::ALL_FLAGS.len() because *Flags has to always be in sync with the enum as it wouldn't compile otherwise.
Alternative would be https://doc.rust-lang.org/std/mem/fn.variant_count.html but it's unstable.

@thibault-martinez thibault-martinez changed the title Use ALL_FLAGS length instead of constant Use ALL_FLAGS length instead of manually set associated constant Nov 26, 2023
@thibault-martinez thibault-martinez marked this pull request as ready for review November 26, 2023 21:32
@thibault-martinez thibault-martinez merged commit 65aacac into iotaledger:2.0 Nov 27, 2023
29 of 35 checks passed
@thibault-martinez thibault-martinez deleted the use-all-flag-length branch November 27, 2023 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants