-
-
Notifications
You must be signed in to change notification settings - Fork 463
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
Undeprecate random #422
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
/// distributions and type-specific generation. | ||
/// | ||
/// # Examples | ||
/// | ||
/// ``` | ||
/// # #![allow(deprecated)] | ||
/// ```rust | ||
/// let x = rand::random::<u8>(); | ||
/// println!("{}", x); | ||
/// | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the |
||
/// # #![allow(deprecated)] | ||
/// use rand::Rng; | ||
/// | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should mention the disadvantages over using There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
#[inline] | ||
pub fn random<T>() -> T where Standard: Distribution<T> { | ||
thread_rng().gen() | ||
|
There was a problem hiding this comment.
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 toRng
) is enough though; we don't need to go over everything here.