Skip to content

Commit

Permalink
Move deprecated gen to bottom of methods
Browse files Browse the repository at this point in the history
  • Loading branch information
vks committed Apr 29, 2024
1 parent dfd2a2b commit b5cc717
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ use core::{mem, slice};
/// # let v = foo(&mut thread_rng());
/// ```
pub trait Rng: RngCore {
/// Alias for [`Rng::random`].
#[inline]
#[deprecated(since="0.9.0", note="This method conflicts with a keyword in Rust 2024. Use `Rng::random` instead.")]
fn gen<T>(&mut self) -> T
where Standard: Distribution<T> {
self.random()
}

/// Return a random value via the [`Standard`] distribution.
///
/// # Example
Expand Down Expand Up @@ -329,6 +321,14 @@ pub trait Rng: RngCore {
let d = distributions::Bernoulli::from_ratio(numerator, denominator).unwrap();
self.sample(d)
}

/// Alias for [`Rng::random`].
#[inline]
#[deprecated(since="0.9.0", note="Renamed to `random` to avoid conflict with the new `gen` keyword in Rust 2024.")]
fn gen<T>(&mut self) -> T
where Standard: Distribution<T> {
self.random()
}
}

impl<R: RngCore + ?Sized> Rng for R {}
Expand Down

0 comments on commit b5cc717

Please sign in to comment.