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

Change to use array::from_fn in Distribution<[T; N]> for StandardUniform #1583

Merged
merged 1 commit into from
Feb 9, 2025

Conversation

sorairolake
Copy link
Contributor

@sorairolake sorairolake commented Feb 9, 2025

  • Added a CHANGELOG.md entry

Summary

Change Distribution<[T; N]> for StandardUniform to use array::from_fn to create an array.

Motivation

  • Reduce the unsafe code.
  • Simplify the code.

Details

I learned this function from rust-lang/rust#136732 (comment).

The external behavior of this function should be preserved before and after this change. This function was stabilized in Rust 1.63.0, and the MSRV of rand crate is Rust 1.63, so we can use it.

Change `Distribution<[T; N]> for StandardUniform` to use
`array::from_fn` to create an array. This reduces the `unsafe` code.
Copy link
Member

@dhardy dhardy left a comment

Choose a reason for hiding this comment

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

LGTM

@dhardy dhardy merged commit e0a70fd into rust-random:master Feb 9, 2025
15 checks passed
@sorairolake sorairolake deleted the change-to-use-from-fn branch February 9, 2025 09:37
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