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

Rename WeightedError → WeightError; add IndexedRandom, IndexedMutRandom #1382

Merged
merged 8 commits into from
Feb 15, 2024

Conversation

dhardy
Copy link
Member

@dhardy dhardy commented Feb 9, 2024

Fixes #1307. CC @LikeLakers2.

Renames WeightedErrorWeightError, revises variants and re-exports from rand::seq.

Adjusts WeightError cases: WeightedTreeIndex (NaNs and try_sample @xmakro) and rand::seq::index::sample_weighted (replace panic; catch too-many-zeros).

Splits SliceRandom into multiple traits to solve #1307. I'm not wildly keen on the result but don't currently have a better idea.

@LikeLakers2
Copy link

I took a general look at 06fe3d8 (the commit where you split SliceRandom).

Unless I'm missing something (it's been a while since I touched rand, so I'm going off of what I put in #1307, plus my own intuition), I believe you've solved the issue I had. So thank you.

I'm not wildly keen on the result but don't currently have a better idea.

Personally, I'm a fan of this solution. Not only does it make it possible for non-std collections to implement random functionality, but it makes it as simple as impl-ing one method on one trait.

Still, if you come up with a better idea, don't be afraid to poke me and I'll tell you what I think.

Copy link
Collaborator

@TheIronBorn TheIronBorn left a 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

@dhardy
Copy link
Member Author

dhardy commented Feb 15, 2024

Thanks @TheIronBorn

@dhardy dhardy merged commit dba696e into rust-random:master Feb 15, 2024
10 of 12 checks passed
dhardy added a commit to dhardy/rand that referenced this pull request Feb 18, 2024
@dhardy dhardy deleted the choose_for_indexed branch July 8, 2024 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants