Skip to content

Add SysRng behind new feature sys_rng - #751

Merged
dhardy merged 19 commits into
masterfrom
push-tqlwtzsrywpy
Nov 24, 2025
Merged

Add SysRng behind new feature sys_rng#751
dhardy merged 19 commits into
masterfrom
push-tqlwtzsrywpy

Conversation

@dhardy

Copy link
Copy Markdown
Member

This was mentioned elsewhere: rust-random/rand#1675

Adds rand_core as a dependency, which is one small crate.

This attempts to enable testing of rng in all CI tests.

@dhardy

Copy link
Copy Markdown
MemberAuthor

@newpavlov your opinion on this please?

There is an alternative: the rand_os crate. I slightly prefer fewer crates but either is acceptable.

@newpavlov

Copy link
Copy Markdown
Member

As I wrote previously, personally, I have a slight preference for a separate crate. But I would be fine with this PR as well, if others prefer it.

P.S.: Note that rand_os recently got an "unmaintained" advisory: rustsec/advisory-db#2462

@josephlrjosephlr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I wrote previously, personally, I have a slight preference for a separate crate. But I would be fine with this PR as well, if others prefer it.

I think I would slightly lean towards having this as part of getrandom. A non-default additive feature seems like a good fit. I think the only complexity is figuring out what (if anything) this crate should re-export from rand_core.

Comment thread.github/workflows/tests.yml Outdated
Comment threadCargo.toml Outdated
Comment threadsrc/rng.rs Outdated
Comment threadsrc/rng.rs Outdated
Comment threadsrc/lib.rs Outdated
Comment threadsrc/rng.rs Outdated
Comment threadsrc/lib.rs Outdated
@dhardy

Copy link
Copy Markdown
MemberAuthor

Thanks for moving this forward @josephlr. I think I addressed your concerns (except as commented).

Comment threadsrc/rng.rs Outdated
Comment threadCargo.toml Outdated
Comment threadsrc/rng.rs Outdated
@dhardy

Copy link
Copy Markdown
MemberAuthor

@newpavlov I addressed your concerns

Comment threadsrc/rng.rs Outdated
Comment threadtests/rng.rs Outdated
Comment threadsrc/lib.rs Outdated
Comment thread.github/workflows/tests.yml Outdated
Comment threadsrc/sys_rng.rs
Comment threadsrc/sys_rng.rs Outdated
@newpavlov

newpavlov commented Nov 23, 2025

Copy link
Copy Markdown
Member

@josephlr
WDYT? It looks like the only unresolved question is whether we need to introduce UnwrappedSysRng or not.

@dhardy
Please add #![cfg_attr(docsrs, feature(doc_cfg))] as per the comment above and add a changelog entry.

@newpavlovnewpavlov changed the title Add OsRng to getrandomAdd SysRng to getrandomNov 23, 2025
@newpavlovnewpavlov changed the title Add SysRng to getrandomAdd feature-gated SysRng type implementing rand_core traitsNov 23, 2025
@dhardy

Copy link
Copy Markdown
MemberAuthor

@newpavlov see lib.rs:12.

@dhardy

Copy link
Copy Markdown
MemberAuthor

A consequence of renaming the feature to sys_rng is:
image
Would it be better just to name the feature rng?

@dhardy

Copy link
Copy Markdown
MemberAuthor

I added UnwrappedSysRng (with a slight doc tweak)

@newpavlov

Copy link
Copy Markdown
Member

What about changelog?

It could worth to add test_unwrapped_sys_rng.

Would it be better just to name the feature rng?

Personally, I don't see a problem with the provided rendering.

@dhardy

Copy link
Copy Markdown
MemberAuthor

Added CHANGELOG entry and test case.

Comment threadtests/sys_rng.rs Outdated
@newpavlovnewpavlov changed the title Add feature-gated SysRng type implementing rand_core traitsAdd SysRng and UnwrappedSysRng behind new feature sys_rngNov 24, 2025
@newpavlovnewpavlov changed the title Add SysRng and UnwrappedSysRng behind new feature sys_rngAdd SysRng behind new feature sys_rngNov 24, 2025
@dhardy
dhardy merged commit 6cbbcb4 into masterNov 24, 2025
75 checks passed
@dhardy
dhardy deleted the push-tqlwtzsrywpy branch November 24, 2025 11:23

@josephlrjosephlr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (sorry for the delay on review), will respond about UnwrappedSysRng in #754

takumi-earth pushed a commit to earthlings-dev/getrandom that referenced this pull request Jan 27, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@dhardy@newpavlov@josephlr