Skip to content

Commit 2def04e

Browse files
committed
Small doc tweaks
1 parent edbaf4d commit 2def04e

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

src/lib.rs

+18-9
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,12 @@ pub mod isaac {
260260
#[cfg(feature="std")] mod thread_rng;
261261

262262

263-
/// A type that can be randomly generated using an `Rng`.
263+
/// A type that can be randomly generated using an [`Rng`].
264264
///
265265
/// This is merely an adaptor around the [`Uniform`] distribution for
266266
/// convenience and backwards-compatibility.
267267
///
268+
/// [`Rng`]: trait.Rng.html
268269
/// [`Uniform`]: distributions/struct.Uniform.html
269270
#[deprecated(since="0.5.0", note="replaced by distributions::Uniform")]
270271
pub trait Rand : Sized {
@@ -734,7 +735,7 @@ impl<R: RngCore> Iterator for AsciiGenerator<R> {
734735

735736

736737
/// A convenient way to seed new algorithmic generators with fresh entropy from
737-
/// `EntropyRng`.
738+
/// [`EntropyRng`].
738739
///
739740
/// This is the recommended way to create PRNGs, unless a deterministic seed is
740741
/// desired (in which case [`SeedableRng::from_seed`] should be used).
@@ -751,6 +752,7 @@ impl<R: RngCore> Iterator for AsciiGenerator<R> {
751752
/// println!("Random die roll: {}", rng.gen_range(1, 7));
752753
/// ```
753754
///
755+
/// [`EntropyRng`]: struct.EntropyRng.html
754756
/// [`SeedableRng`]: https://docs.rs/rand_core/0.1/rand_core/trait.SeedableRng.html
755757
/// [`SeedableRng::from_seed`]: https://docs.rs/rand_core/0.1/rand_core/trait.SeedableRng.html#tymethod.from_seed
756758
#[cfg(feature="std")]
@@ -802,9 +804,10 @@ impl<R: SeedableRng> NewRng for R {
802804
/// future library versions may use a different internal generator with
803805
/// different output. Further, this generator may not be portable and can
804806
/// produce different output depending on the architecture. If you require
805-
/// reproducible output, use a named RNG, for example `ChaChaRng`.
807+
/// reproducible output, use a named RNG, for example [`ChaChaRng`].
806808
///
807809
/// [HC-128]: prng/hc128/struct.Hc128Rng.html
810+
/// [`ChaChaRng`]: prng/chacha/struct.ChaChaRng.html
808811
#[derive(Clone, Debug)]
809812
pub struct StdRng(Hc128Rng);
810813

@@ -845,19 +848,19 @@ impl CryptoRng for StdRng {}
845848
/// An RNG recommended when small state, cheap initialization and good
846849
/// performance are required. The PRNG algorithm in `SmallRng` is chosen to be
847850
/// efficient on the current platform, **without consideration for cryptography
848-
/// or security**. The size of its state is much smaller than for `StdRng`.
851+
/// or security**. The size of its state is much smaller than for [`StdRng`].
849852
///
850853
/// Reproducibility of output from this generator is however not required, thus
851854
/// future library versions may use a different internal generator with
852855
/// different output. Further, this generator may not be portable and can
853856
/// produce different output depending on the architecture. If you require
854-
/// reproducible output, use a named RNG, for example `XorShiftRng`.
857+
/// reproducible output, use a named RNG, for example [`XorShiftRng`].
855858
///
856859
/// The current algorithm used on all platforms is [Xorshift].
857860
///
858861
/// # Examples
859862
///
860-
/// Initializing `StdRng` with a random seed can be done using `NewRng`:
863+
/// Initializing `SmallRng` with a random seed can be done using [`NewRng`]:
861864
///
862865
/// ```
863866
/// # use rand::Rng;
@@ -869,7 +872,7 @@ impl CryptoRng for StdRng {}
869872
/// # let v: u32 = small_rng.gen();
870873
/// ```
871874
///
872-
/// When initializing a lot of `SmallRng`, using `thread_rng` can be more
875+
/// When initializing a lot of `SmallRng`'s, using [`thread_rng`] can be more
873876
/// efficient:
874877
///
875878
/// ```
@@ -887,7 +890,11 @@ impl CryptoRng for StdRng {}
887890
/// .collect();
888891
/// ```
889892
///
890-
/// [Xorshift]: struct.XorShiftRng.html
893+
/// [`NewRng`]: trait.NewRng.html
894+
/// [`StdRng`]: struct.StdRng.html
895+
/// [`thread_rng`]: fn.thread_rng.html
896+
/// [Xorshift]: prng/struct.XorShiftRng.html
897+
/// [`XorShiftRng`]: prng/struct.XorShiftRng.html
891898
#[derive(Clone, Debug)]
892899
pub struct SmallRng(XorShiftRng);
893900

@@ -923,7 +930,7 @@ impl SeedableRng for SmallRng {
923930
}
924931
}
925932

926-
/// DEPRECATED: use `SmallRng` instead.
933+
/// DEPRECATED: use [`SmallRng`] instead.
927934
///
928935
/// Create a weak random number generator with a default algorithm and seed.
929936
///
@@ -933,6 +940,8 @@ impl SeedableRng for SmallRng {
933940
/// create the `Rng` yourself.
934941
///
935942
/// This will seed the generator with randomness from `thread_rng`.
943+
///
944+
/// [`SmallRng`]: struct.SmallRng.html
936945
#[deprecated(since="0.5.0", note="removed in favor of SmallRng")]
937946
#[cfg(feature="std")]
938947
pub fn weak_rng() -> XorShiftRng {

src/os.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ use std::fmt;
1515
use rand_core::{RngCore, Error, impls};
1616

1717
/// A random number generator that retrieves randomness straight from the
18-
/// operating system. This is the preferred external source of entropy for most
18+
/// operating system.
19+
///
20+
/// This is the preferred external source of entropy for most
1921
/// applications. Commonly it is used to initialize a user-space RNG, which can
2022
/// then be used to generate random values with much less overhead than `OsRng`.
2123
///

src/thread_rng.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ use reseeding::ReseedingRng;
4545
const THREAD_RNG_RESEED_THRESHOLD: u64 = 32*1024*1024; // 32 MiB
4646

4747
/// The type returned by [`thread_rng`], essentially just a reference to the
48-
/// PRNG in thread-local memory. Cloning this handle just produces a new
49-
/// reference to the same thread-local generator.
48+
/// PRNG in thread-local memory.
49+
///
50+
/// Cloning this handle just produces a new reference to the same thread-local
51+
/// generator.
5052
///
5153
/// [`thread_rng`]: fn.thread_rng.html
5254
#[derive(Clone, Debug)]

0 commit comments

Comments
 (0)