Skip to content

core: implement bounded random sampling#159592

Open
joboet wants to merge 1 commit into
rust-lang:mainfrom
joboet:range_distribution
Open

core: implement bounded random sampling#159592
joboet wants to merge 1 commit into
rust-lang:mainfrom
joboet:range_distribution

Conversation

@joboet

@joboet joboet commented Jul 20, 2026

Copy link
Copy Markdown
Member

Tracking issue: #130703

This PR implements the Distribution trait for RangeInclusive, allowing random sampling from within a range. I chose Lemire's algorithm, which is also used in FreeBSD's arc4random_uniform.

I've only implemented this for core::range::RangeInclusive to prevent typo-errors. Perhaps it makes sense though to extend the support to core::ops::RangeInclusive?

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 20, 2026
@rustbot

rustbot commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

r? @JohnTitor

rustbot has assigned @JohnTitor.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 12 candidates
  • Random selection from 6 candidates

@joboet joboet added the A-random Area: random data generation support label Jul 20, 2026
@rust-log-analyzer

This comment has been minimized.

@joboet joboet added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Jul 20, 2026
@joboet
joboet force-pushed the range_distribution branch from 7cf121f to d3e55bf Compare July 20, 2026 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-random Area: random data generation support S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants