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

Fix builder to use provided rng #150

Merged
merged 1 commit into from
Nov 16, 2023
Merged

Fix builder to use provided rng #150

merged 1 commit into from
Nov 16, 2023

Conversation

Benjscho
Copy link
Collaborator

@Benjscho Benjscho commented Nov 16, 2023

This commit fixes the turmoil sim builder by removing the rng
function. Currently the build function ignores the rng set on the
builder, and due to the boxing of the value there is no easy way to
repeatedly build a sim with the same rng. We would need to add the
ability to clone the boxed rng, which requires some complicated trait
bounds and a different breaking of the interface. This is simpler and
fixes the bug where rng was ignored during building.

This is a breaking change:

  • rng is removed from the builder, as it was not delivering its
    expected behaviour. Users now need to explicitly specify
    build_with_rng.

@mcches mcches self-requested a review November 16, 2023 16:41
This commit fixes the turmoil sim builder by removing the `rng`
function. Currently the `build` function ignores the `rng` set on the
builder, and due to the boxing of the value there is no easy way to
repeatedly build a sim with the same `rng`. We would need to add the
ability to clone the boxed rng, which requires some complicated trait
bounds and a different breaking of the interface. This is simpler and
fixes the bug where rng was ignored during building.

This is a breaking change:
- `rng` is removed from the builder, as it was not delivering its
  expected behaviour. Users now need to explicitly specify
  `build_with_rng`.
Copy link
Contributor

@mcches mcches left a comment

Choose a reason for hiding this comment

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

Approved with one minor doc nit.

pub fn build_with_rng<'a>(&self, rng: Box<dyn RngCore>) -> Sim<'a> {
/// Build a sim with a provided `rng`.
///
/// This allows setting the random number generator used to fuzz
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// This allows setting the random number generator used to fuzz
/// This allows setting the random number generator used to fuzz.

@mcches mcches merged commit 3584b22 into tokio-rs:main Nov 16, 2023
3 checks passed
/// Build a sim with a provided `rng`.
///
/// This allows setting the random number generator used to fuzz
fn build_with_rng<'a>(&self, rng: Box<dyn RngCore>) -> Sim<'a> {
Copy link

Choose a reason for hiding this comment

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

Hey, just so you know, the function was public before and isn't anymore, is that by design?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, this was a mistake. It should be fixed after #152 is merged

mcches pushed a commit that referenced this pull request Nov 17, 2023
Add documentation to the sim builder and the config, particularly
focused on default values.

Also fix a few errors that emerged from running `cargo doc`, and make
`build_with_rng` public again (mistake in #150).
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.

3 participants