Skip to content

Commit 3898e00

Browse files
committed
Small doc polishing
1 parent 6b018bb commit 3898e00

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ impl<R: RngCore + ?Sized> Rng for R {}
642642
/// PRNGs, though two alternatives may be considered:
643643
///
644644
/// * Deterministic creation using [`SeedableRng::from_seed`] with a fixed seed
645-
/// * Seeding from `thread_rng`: `SeedableRng::from_rng(thread_rng())?`;
645+
/// * Seeding from [`thread_rng`]: `SeedableRng::from_rng(thread_rng())?`;
646646
/// this will usually be faster and should also be secure, but requires
647647
/// trusting one extra component.
648648
///
@@ -658,6 +658,7 @@ impl<R: RngCore + ?Sized> Rng for R {}
658658
/// [`EntropyRng`]: rngs/struct.EntropyRng.html
659659
/// [`SeedableRng`]: trait.SeedableRng.html
660660
/// [`SeedableRng::from_seed`]: trait.SeedableRng.html#tymethod.from_seed
661+
/// [`thread_rng`]: fn.thread_rng.html
661662
#[cfg(feature="std")]
662663
pub trait FromEntropy: SeedableRng {
663664
/// Creates a new instance, automatically seeded with fresh entropy.
@@ -703,6 +704,9 @@ impl<R: SeedableRng> FromEntropy for R {
703704
/// documentation of the entropy source and [`Standard`] for documentation of
704705
/// distributions and type-specific generation.
705706
///
707+
/// Use [`thread_rng`] directly when you need more features, for example
708+
/// `thread_rng().gen_range(a, b)` to generate values uniformly in some range.
709+
///
706710
/// # Examples
707711
///
708712
/// ```

src/rngs/entropy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ use {OsRng, JitterRng};
3030
/// external entropy then primarily use the local PRNG ([`thread_rng`] is
3131
/// provided as a convenient, local, automatically-seeded CSPRNG).
3232
///
33-
/// [`OsRng`]: os/struct.OsRng.html
34-
/// [`JitterRng`]: jitter/struct.JitterRng.html
33+
/// [`OsRng`]: struct.OsRng.html
34+
/// [`JitterRng`]: struct.JitterRng.html
3535
/// [`thread_rng`]: ../fn.thread_rng.html
3636
#[derive(Debug)]
3737
pub struct EntropyRng {

src/rngs/read.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ use rand_core::{RngCore, Error, ErrorKind, impls};
2323
///
2424
/// `ReadRng` uses `std::io::read_exact`, which retries on interrupts. All other
2525
/// errors from the underlying reader, including when it does not have enough
26-
/// data, will only be reported through `try_fill_bytes`. The other `RngCore`
27-
/// methods will panic in case of an error error.
26+
/// data, will only be reported through [`try_fill_bytes`]. The other
27+
/// [`RngCore`] methods will panic in case of an error.
2828
///
2929
/// # Example
3030
///
@@ -35,6 +35,9 @@ use rand_core::{RngCore, Error, ErrorKind, impls};
3535
/// let mut rng = read::ReadRng::new(&data[..]);
3636
/// println!("{:x}", rng.gen::<u32>());
3737
/// ```
38+
///
39+
/// [`RngCore`]: ../trait.RngCore.html
40+
/// [`try_fill_bytes`]: ../trait.RngCore.html#tymethod.try_fill_bytes
3841
#[derive(Debug)]
3942
pub struct ReadRng<R> {
4043
reader: R

src/rngs/small.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ use {RngCore, SeedableRng, Error};
1414
use prng::XorShiftRng;
1515

1616
/// An RNG recommended when small state, cheap initialization and good
17-
/// performance are required. The PRNG algorithm in `SmallRng` is chosen to be
18-
/// efficient on the current platform, **without consideration for cryptography
19-
/// or security**. The size of its state is much smaller than for [`StdRng`].
17+
/// performance are required.
18+
///
19+
/// The PRNG algorithm in `SmallRng` is chosen to be efficient on the current
20+
/// platform, **without consideration for cryptography or security**. The size
21+
/// of its state is much smaller than for [`StdRng`].
2022
///
2123
/// Reproducibility of output from this generator is however not required, thus
2224
/// future library versions may use a different internal generator with

0 commit comments

Comments
 (0)