Add new type similar to AtLeastOne
to enforce min/max size constraints and use it instead of Vec
s in AdjustedDifficulty
#8484
Labels
A-rust
Area: Updates to Rust code
C-cleanup
Category: This is a cleanup
C-tech-debt
Category: Code maintainability issues
S-needs-triage
Status: A bug report needs triage
Motivation
There's repetitive code around taking a constant number of items from an iterator to collect into a
Vec
, and there are max size constraints that aren't currently enforced inAdjustedDifficulty
methods.It would be easier to maintain and verify correctness if we had a struct that handled this logic instead.
Design
Create a new type similar to
AtLeastOne
with a const generic for max size, which:take()
to ensure the max size is enforced, andEither:
AtLeastOne
as the inner type to check that there's at least one element, ormin
size (optional)Currently the minimum length for this use case is 1, so using
AtLeastOne
as the inner type would suffice.The text was updated successfully, but these errors were encountered: