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 rand-core sub-crate and update version numbers #288

Merged
merged 4 commits into from
Mar 14, 2018

Conversation

dhardy
Copy link
Member

@dhardy dhardy commented Mar 8, 2018

  • This moves core traits/types/impls to rand-core
  • impls and le modules are now public (from rand-core only)
  • CI tweaks, needed since not all features are duplicated on rand-core
  • Cross-crate doc links now use full URLs (is there a better option?); I should note @burdges predicted this would be an issue; also we can't really test the links until after publication

@vks
Copy link
Collaborator

vks commented Mar 8, 2018

Looks good to me.

Copy link
Contributor

@pitdicker pitdicker 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! Left a few small comments.

Core functionality for the [rand] library.

This crate contains the core trait, `RngCore`, and some extension traits. This
should be sufficient for libraries publishing an `RngCore` implementation,
Copy link
Contributor

Choose a reason for hiding this comment

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

This reads a like a suggestion, but we prefer RNG implementations to only depend on this crate, right? Can you reword a little?

`rand` is primarily distributed under the terms of both the MIT
license and the Apache License (Version 2.0).

See LICENSE-APACHE, and LICENSE-MIT for details.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the license files (and the changelog) also be copied to the rand-core directory?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know, but that appears necessary to get the licence files inside the Cargo package, so I will add them.

//!
//! The `impls` and `le` sub-modules include a few small functions to assist
//! implementation of `RngCore`. Since this module is only of interest to
//! `RngCore` implementors, it is not re-exported from `rand`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Old comment?

///
/// This trait encapsulates the low-level functionality common to all
/// generators, and is the "back end", to be implemented by generators.
/// End users should normally use [`Rng`] instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

This sounds like an old comment. Maybe point to the rand crate now, instead of only the Rng trait. (also in the rest of this comment block)

/// This trait encapsulates the low-level functionality common to all
/// pseudo-random number generators (PRNGs, or algorithmic generators).
///
/// Normally users should use the [`NewRng`] extension trait, excepting when a
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe point to rand?

///
/// Seeding a small PRNG from another small PRNG is possible, but
/// something to be careful with. An extreme example of how this can go
/// wrong is seeding an [`XorShiftRng`] from another [`XorShiftRng`], which
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still want this link to XorShiftRng? I removed it in the original PR because of the crate separation.

Copy link
Member Author

Choose a reason for hiding this comment

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

I decided to keep this paragraph as is since it provides a clear warning and only mentions Xorshift as an example (we could even remove the link and it would still be clear).

This does leave a couple of cross-crate doc links, but I don't see a major problem (as long as we keep the number small).

@pitdicker
Copy link
Contributor

Is now the right time to bring up if we should remove the default implementations in RngCore? I think it was even in the RFC discussion that we should not have default implementations, because the best choice depends on the RNG, and it makes wrappers more error prone. I prefer to see one release which bundles breaking changes to two releases.

b.t.w. I upgraded my small-rngs repository to this PR (still local). We had quite some name changes in the last two months 😄. But it was easy, and works!

@dhardy
Copy link
Member Author

dhardy commented Mar 9, 2018

Agreed, default implementations is an issue to discuss. I'd like to try implementing some type of #[derive(RngCore)] support, at least for the case of wrapper types like StdRng.

Okay, I'll go over the documentation again.

This moves core traits/types/impls to rand-core
impls and le modules are now public (from rand-core only)
CI tweaks, needed since not all features are duplicated on rand-core
Cross-crate doc links now use full URLs (is there a better option?)
@dhardy
Copy link
Member Author

dhardy commented Mar 10, 2018

Updated. Are you happy with this @pitdicker?

The update adds two unrelated changes which might want extra attention:

  • removal of default impls of RngCore methods (as mentioned above)
  • part of No sizing #291 (could be removed from this PR I guess)

@pitdicker
Copy link
Contributor

Yes I am happy with it 😄, and very nice documentation. Ready to merge?

@dhardy
Copy link
Member Author

dhardy commented Mar 11, 2018

Good! But no, I'm hoping to get a little more feedback on #291 first.

@dhardy dhardy mentioned this pull request Mar 11, 2018
33 tasks
@dhardy dhardy added the P-high Priority: high label Mar 12, 2018
@dhardy
Copy link
Member Author

dhardy commented Mar 14, 2018

Rebased without change from #291.

@dhardy dhardy merged commit 31f2663 into rust-random:master Mar 14, 2018
@dhardy dhardy deleted the core branch March 14, 2018 10:47
@dhardy dhardy mentioned this pull request Mar 14, 2018
pitdicker pushed a commit that referenced this pull request Apr 4, 2018
Add rand-core sub-crate and update version numbers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-high Priority: high
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants