Skip to content

fix(tool): update rand crate to the latest version #216

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 1 commit into from
Nov 19, 2018

Conversation

sendilkumarn
Copy link
Contributor

Fixes a part of #165

Copy link
Collaborator

@Yoric Yoric left a comment

Choose a reason for hiding this comment

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

I think you added one file by accident.

json::from(string)
}
TypeSpec::Number => {
json::from(rng.next_f64())
json::from(rng.next_u64())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hey, I want f64, not u64 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sadly, that was removed

Copy link
Collaborator

@Yoric Yoric Nov 17, 2018

Choose a reason for hiding this comment

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

This seems to suggest that there's still a way, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okayes, let me do it differently.

rng.gen::<f64>() would do

yarn.lock Outdated
@@ -0,0 +1,362 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wait, why is this updating yarn.lock?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

my yarn version is different, this should not be here I will remove it

.clone()
// rng.choose(&[Identity, Gzip, /* Deflate is apprently broken https://github.com/alexcrichton/flate2-rs/issues/151 , */ Brotli /*, Lzw doesn't work yet */])
// .unwrap()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you remove that code instead of commenting it out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad 👍

let float = rng.next_f64();
float < CHANCES_TO_SKIP
fn should_skip(rng: &mut RngCore) -> bool {
let float = rng.next_u64();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same problem of f64 :)

Since CHANCES_TO_SKIP <= 1, by using next_u64, you're effectively skipping only if your result is 0, which happens roughly 1/2^64 times, i.e. never :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@Yoric
Copy link
Collaborator

Yoric commented Nov 19, 2018

Could you:

  • fix the build problem;
  • fold your patches into a single one?

remove yarn lock file

use sliceRandom instead of deprecated choose method

remove yarn lock

clean and move u64 to f64 rng

fix test roundtrip
@sendilkumarn
Copy link
Contributor Author

@Yoric Done 👍 There are a lot of changes in the rand crate, took a little time to get it.

Copy link
Collaborator

@Yoric Yoric left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@Yoric
Copy link
Collaborator

Yoric commented Nov 19, 2018

Feel free to merge when you're ready!

@sendilkumarn
Copy link
Contributor Author

I don't have write access 😢

@Yoric Yoric merged commit d477a47 into binast:master Nov 19, 2018
@sendilkumarn sendilkumarn deleted the rand-update branch November 19, 2018 17:03
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