-
-
Notifications
You must be signed in to change notification settings - Fork 433
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
Add .choices() method to the Slice distribution #1402
Conversation
Signed-off-by: Justus Fluegel <[email protected]>
Signed-off-by: Justus Fluegel <[email protected]>
I am not quite sure if that changelog format I am using here is correct so I would appreciate someone looking over that and giving me a short reply :) |
a609bd4
to
b6b8b5a
Compare
Signed-off-by: Justus Fluegel <[email protected]>
Sorry I kinda messed up my commits here, wanted to keep a clean history so force-pushed to my branch ( shouldn't really matter on your end either way ) |
No worries about commit history; we squash in this repo. (Personally I still force-push often enough.) |
…call time Signed-off-by: Justus Fluegel <[email protected]>
Signed-off-by: Justus Fluegel <[email protected]>
Signed-off-by: Justus Fluegel <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little unorthodox, but seems fine to me. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
CI failure is a false positive from the new |
yep I figured :) |
Is there some information on the release cycle of rand somewhere ( Is there a date when this will be in alpha / stable )? Don't want to push you to release something, just some information on when I should check back here would be nice :) |
There's a tracking issue for 0.9. We're a little slow making releases, but I'll push out a second alpha soon. |
thanks 👍 |
CHANGELOG.md
entrySummary
Add a
.choices() -> NonZeroUsize
method to the slices distributionMotivation
In one of my projects we use a Slice Distribution for the input of a constructor for a type which needs to generate some element of that slice & at the same time a boolean for another variable with the same probability of each element in the Distribution occurring. A simple
1 / distr.choices()
would help us a lot in that regards.Details
Adds the
Slices::choices() - NonZeroUsize
method, which returns the count of different choices in the input vector (counting duplicates in that vector as well)