You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in order to choose a random variant in an enum (with help of Peternator7/strum#297), I would like to use rand::seq::gen_index as index, as it would suppress the need for Option, Iterator, etc.
But it is not marked public.
Would it be possible ? I could just copy/paste it but maybe others need it.
We could, though it's not much code to copy+paste. Specifically for enum variants, you are surely never going to be sampling larger than u32::MAX anyway?
Activity
TheIronBorn commentedon Jan 17, 2024
What does
gen_indexprovide for you thatgen_rangedoesn't?dhardy commentedon Jan 18, 2024
We could, though it's not much code to copy+paste. Specifically for enum variants, you are surely never going to be sampling larger than
u32::MAXanyway?AdrienPensart commentedon Jan 18, 2024
Yes only small usize values.
dhardy commentedon Jan 19, 2024
So why not copy but simplify to only the 32-bit path?
Actually, can't you determine the number of variants and select an appropriate method at compile time?
AdrienPensart commentedon Jan 19, 2024
I copy/pasted the function, thanks!