10000 feat: add `random`, `random_with`, `randomize`, `randomize_with` methods by DaniPopes · Pull Request #444 · recmo/uint · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: add random, random_with, randomize, randomize_with methods #444

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

Merged
merged 3 commits into from
Mar 13, 2025

Conversation

DaniPopes
Copy link
Contributor
@DaniPopes DaniPopes commented Feb 28, 2025

Closes #440.

@DaniPopes DaniPopes requested a review from prestwich as a code owner February 28, 2025 18:53
@DaniPopes DaniPopes force-pushed the randomize-fns branch 3 times, most recently from e861a9f to fe7c7ee Compare February 28, 2025 19:30
pub fn random() -> Self {
// SAFETY: `uint` is only accessible after random initialization.
#[allow(clippy::uninit_assumed_init)]
let mut uint = unsafe { core::mem::MaybeUninit::<Self>::uninit().assume_init() };
Copy link
Collaborator

Choose a reason for hiding this comment

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

why unsafety here instead of Uint::ZERO?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

uses undefined memory instead of zeroing it

@prestwich prestwich enabled auto-merge March 13, 2025 15:42
@prestwich prestwich merged commit 5bab688 into recmo:main Mar 13, 2025
17 checks passed
@DaniPopes DaniPopes deleted the randomize-fns branch March 25, 2025 15:11
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.

Add random* methods on Uint
2 participants
0