Skip to content

Undeprecate random #422

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
May 3, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/thread_rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,15 @@ impl RngCore for ThreadRng {

impl CryptoRng for ThreadRng {}

/// DEPRECATED: use `thread_rng().gen()` instead.
///
/// Generates a random value using the thread-local random number generator.
///
/// This is simply a shortcut for `thread_rng().gen()`. See [`thread_rng`] for
/// documentation of the entropy source and [`Rand`] for documentation of
/// documentation of the entropy source and [`Standard`] for documentation of
Copy link
Member

Choose a reason for hiding this comment

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

Add a quick mention of using thread_rng().gen_range(a, b) here? That (and maybe a link to Rng) is enough though; we don't need to go over everything here.

/// distributions and type-specific generation.
///
/// # Examples
///
/// ```
/// # #![allow(deprecated)]
/// ```rust
/// let x = rand::random::<u8>();
/// println!("{}", x);
///
Expand All @@ -146,7 +143,7 @@ impl CryptoRng for ThreadRng {}
/// If you're calling `random()` in a loop, caching the generator as in the
/// following example can increase performance.
///
/// ```
/// ```rust
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the rust is redundant. (However, I guess it does not hurt to be explicit.)

/// # #![allow(deprecated)]
/// use rand::Rng;
///
Expand All @@ -166,8 +163,7 @@ impl CryptoRng for ThreadRng {}
/// ```
///
/// [`thread_rng`]: fn.thread_rng.html
/// [`Rand`]: trait.Rand.html
#[deprecated(since="0.5.0", note="removed in favor of thread_rng().gen()")]
/// [`Standard`]: distributions/struct.Standard.html
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we should mention the disadvantages over using thread_rng().gen() here.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is needed — there's already a note about caching the thread_rng handle above

#[inline]
pub fn random<T>() -> T where Standard: Distribution<T> {
thread_rng().gen()
Expand Down