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

Add the rand module #100

Merged
merged 3 commits into from
Sep 22, 2020
Merged

Add the rand module #100

merged 3 commits into from
Sep 22, 2020

Conversation

Absolucy
Copy link
Contributor

@Absolucy Absolucy commented Sep 22, 2020

Adds the rand module.

Exposes two types: rand::WyRand and rand::Pcg64, which are RNGs. Each has the following functions: int() -> Integer and int_range(lower: Integer, upper: Integer) -> Integer

In addition, rand::int[_range] exposes a single-use WyRand generator

aspen added 2 commits September 22, 2020 14:53
revert(modules): Remove `byte`/`byte_range` functions
chore: Add `rand` example script
@udoprog udoprog added the enhancement New feature or request label Sep 22, 2020
Copy link
Collaborator

@udoprog udoprog left a comment

Choose a reason for hiding this comment

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

Module looks great. Could you remove and .gitignore the .idea files?

My impression of IntelliJ is that it does just fine importing projects. And I won't be able to keep them up-to-date seeing as I don't use it. It's different with e.g. .vscode/launch.json, since this is just a generic launch configuration. But an incomplete .idea project listing seems like it could cause editor confusion!

@udoprog
Copy link
Collaborator

udoprog commented Sep 22, 2020

Also looking forward to #73, so we can get somewhere to put api docs :).

}

/// Generate a random integer
fn int(&mut self) -> Value {
Copy link
Collaborator

@udoprog udoprog Sep 22, 2020

Choose a reason for hiding this comment

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

FTR, these can simply return i64. Conversion is handled by Rune (for any type implementing the ToValue trait). Returning a Value doesn't hurt though!

@udoprog udoprog merged commit 28686ba into rune-rs:master Sep 22, 2020
@Absolucy Absolucy deleted the random-module branch September 22, 2020 20:43
@udoprog
Copy link
Collaborator

udoprog commented Sep 22, 2020

Thank you!

@udoprog udoprog added the changelog Issue has been added to the changelog label Sep 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog Issue has been added to the changelog enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants