Skip to content

Add next_u128 and try_next_u128 to Rng and TryRng respectively#78

Closed
Apersoma wants to merge 4 commits into
rust-random:masterfrom
Apersoma:next_u128
Closed

Add next_u128 and try_next_u128 to Rng and TryRng respectively#78
Apersoma wants to merge 4 commits into
rust-random:masterfrom
Apersoma:next_u128

Conversation

@Apersoma
Copy link
Copy Markdown

@Apersoma Apersoma commented May 21, 2026

  • Added a CHANGELOG.md entry

Summary

Added methods to Rng and TryRng to for direct generation of u128s.

Motivation

See: #77

Details

Functions next_u128 and try_next_u128 that generate a u128.
To ensure backwards-compatibility a default implementation was
added that works by concating 2 u64s generated from calls to
(try_)next_u64. The implementation for try_next_u128 prioritizes
reducing branching over reducing calls to try_next_u64.

@Apersoma
Copy link
Copy Markdown
Author

It may also make sense to implement it via fill_bytes

@newpavlov
Copy link
Copy Markdown
Member

Closing as per the comment in the parent issue.

@newpavlov newpavlov closed this May 21, 2026
Sign up for free to 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.

2 participants