|
11 | 11 | //! |
12 | 12 | //! [`Uniform`] is the standard distribution to sample uniformly from a range; |
13 | 13 | //! e.g. `Uniform::new_inclusive(1, 6).unwrap()` can sample integers from 1 to 6, like a |
14 | | -//! standard die. [`Rng::gen_range`] supports any type supported by [`Uniform`]. |
| 14 | +//! standard die. [`Rng::random_range`] supports any type supported by [`Uniform`]. |
15 | 15 | //! |
16 | 16 | //! This distribution is provided with support for several primitive types |
17 | 17 | //! (all integer and floating-point types) as well as [`std::time::Duration`], |
|
33 | 33 | //! let side = Uniform::new(-10.0, 10.0).unwrap(); |
34 | 34 | //! |
35 | 35 | //! // sample between 1 and 10 points |
36 | | -//! for _ in 0..rng.gen_range(1..=10) { |
| 36 | +//! for _ in 0..rng.random_range(1..=10) { |
37 | 37 | //! // sample a point from the square with sides -10 - 10 in two dimensions |
38 | 38 | //! let (x, y) = (rng.sample(side), rng.sample(side)); |
39 | 39 | //! println!("Point: {}, {}", x, y); |
@@ -154,7 +154,7 @@ use serde::{Deserialize, Serialize}; |
154 | 154 | /// [`Uniform::new`] and [`Uniform::new_inclusive`] construct a uniform |
155 | 155 | /// distribution sampling from the given range; these functions may do extra |
156 | 156 | /// work up front to make sampling of multiple values faster. If only one sample |
157 | | -/// from the range is required, [`Rng::gen_range`] can be more efficient. |
| 157 | +/// from the range is required, [`Rng::random_range`] can be more efficient. |
158 | 158 | /// |
159 | 159 | /// When sampling from a constant range, many calculations can happen at |
160 | 160 | /// compile-time and all methods should be fast; for floating-point ranges and |
@@ -186,18 +186,18 @@ use serde::{Deserialize, Serialize}; |
186 | 186 | /// println!("{}", sum); |
187 | 187 | /// ``` |
188 | 188 | /// |
189 | | -/// For a single sample, [`Rng::gen_range`] may be preferred: |
| 189 | +/// For a single sample, [`Rng::random_range`] may be preferred: |
190 | 190 | /// |
191 | 191 | /// ``` |
192 | 192 | /// use rand::Rng; |
193 | 193 | /// |
194 | 194 | /// let mut rng = rand::rng(); |
195 | | -/// println!("{}", rng.gen_range(0..10)); |
| 195 | +/// println!("{}", rng.random_range(0..10)); |
196 | 196 | /// ``` |
197 | 197 | /// |
198 | 198 | /// [`new`]: Uniform::new |
199 | 199 | /// [`new_inclusive`]: Uniform::new_inclusive |
200 | | -/// [`Rng::gen_range`]: Rng::gen_range |
| 200 | +/// [`Rng::random_range`]: Rng::random_range |
201 | 201 | #[derive(Clone, Copy, Debug, PartialEq, Eq)] |
202 | 202 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
203 | 203 | #[cfg_attr(feature = "serde", serde(bound(serialize = "X::Sampler: Serialize")))] |
@@ -406,7 +406,7 @@ where |
406 | 406 | /// Range that supports generating a single sample efficiently. |
407 | 407 | /// |
408 | 408 | /// Any type implementing this trait can be used to specify the sampled range |
409 | | -/// for `Rng::gen_range`. |
| 409 | +/// for `Rng::random_range`. |
410 | 410 | pub trait SampleRange<T> { |
411 | 411 | /// Generate a sample from the given range. |
412 | 412 | fn sample_single<R: RngCore + ?Sized>(self, rng: &mut R) -> Result<T, Error>; |
|
0 commit comments