Skip to content

Commit b451306

Browse files
committed
Use RFC 1946 for doc links
1 parent 4336232 commit b451306

File tree

25 files changed

+206
-333
lines changed

25 files changed

+206
-333
lines changed

rand_chacha/src/chacha.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,8 @@ const STATE_WORDS: usize = 16;
6262
/// [^2]: [eSTREAM: the ECRYPT Stream Cipher Project](
6363
/// http://www.ecrypt.eu.org/stream/)
6464
///
65-
/// [`set_word_pos`]: #method.set_word_pos
66-
/// [`set_stream`]: #method.set_stream
67-
/// [`BlockRng`]: ../rand_core/block/struct.BlockRng.html
68-
/// [`RngCore`]: ../rand_core/trait.RngCore.html
65+
/// [`set_word_pos`]: ChaChaRng::set_word_pos
66+
/// [`set_stream`]: ChaChaRng::set_stream
6967
#[derive(Clone, Debug)]
7068
pub struct ChaChaRng(BlockRng<ChaChaCore>);
7169

rand_core/src/block.rs

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
//! implementations only need to concern themselves with generation of the
1717
//! block, not the various [`RngCore`] methods (especially [`fill_bytes`], where
1818
//! the optimal implementations are not trivial), and this allows
19-
//! [`ReseedingRng`] perform periodic reseeding with very low overhead.
19+
//! `ReseedingRng` (see [`rand`](https://docs.rs/rand) crate) perform periodic
20+
//! reseeding with very low overhead.
2021
//!
2122
//! # Example
2223
//!
@@ -46,10 +47,8 @@
4647
//! type MyRng = BlockRng<u32, MyRngCore>;
4748
//! ```
4849
//!
49-
//! [`BlockRngCore`]: trait.BlockRngCore.html
50-
//! [`RngCore`]: ../trait.RngCore.html
51-
//! [`fill_bytes`]: ../trait.RngCore.html#tymethod.fill_bytes
52-
//! [`ReseedingRng`]: ../../rand/rngs/adapter/struct.ReseedingRng.html
50+
//! [`BlockRngCore`]: crate::block::BlockRngCore
51+
//! [`fill_bytes`]: RngCore::fill_bytes
5352
5453
use core::convert::AsRef;
5554
use core::fmt;
@@ -60,7 +59,7 @@ use impls::{fill_via_u32_chunks, fill_via_u64_chunks};
6059
/// blocks (typically `[u32; N]`). This technique is commonly used by
6160
/// cryptographic RNGs to improve performance.
6261
///
63-
/// See the [module documentation](index.html) for details.
62+
/// See the [module][crate::block] documentation for details.
6463
pub trait BlockRngCore {
6564
/// Results element type, e.g. `u32`.
6665
type Item;
@@ -105,15 +104,10 @@ pub trait BlockRngCore {
105104
///
106105
/// For easy initialization `BlockRng` also implements [`SeedableRng`].
107106
///
108-
/// [`BlockRngCore`]: BlockRngCore.t.html
109-
/// [`BlockRngCore::generate`]: trait.BlockRngCore.html#tymethod.generate
110-
/// [`BlockRng64`]: struct.BlockRng64.html
111-
/// [`RngCore`]: ../RngCore.t.html
112-
/// [`next_u32`]: ../trait.RngCore.html#tymethod.next_u32
113-
/// [`next_u64`]: ../trait.RngCore.html#tymethod.next_u64
114-
/// [`fill_bytes`]: ../trait.RngCore.html#tymethod.fill_bytes
115-
/// [`try_fill_bytes`]: ../trait.RngCore.html#tymethod.try_fill_bytes
116-
/// [`SeedableRng`]: ../SeedableRng.t.html
107+
/// [`next_u32`]: RngCore::next_u32
108+
/// [`next_u64`]: RngCore::next_u64
109+
/// [`fill_bytes`]: RngCore::fill_bytes
110+
/// [`try_fill_bytes`]: RngCore::try_fill_bytes
117111
#[derive(Clone)]
118112
#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
119113
pub struct BlockRng<R: BlockRngCore + ?Sized> {
@@ -314,13 +308,10 @@ impl<R: BlockRngCore + SeedableRng> SeedableRng for BlockRng<R> {
314308
/// values. If the requested length is not a multiple of 8, some bytes will be
315309
/// discarded.
316310
///
317-
/// [`BlockRngCore`]: BlockRngCore.t.html
318-
/// [`RngCore`]: ../RngCore.t.html
319-
/// [`next_u32`]: ../trait.RngCore.html#tymethod.next_u32
320-
/// [`next_u64`]: ../trait.RngCore.html#tymethod.next_u64
321-
/// [`fill_bytes`]: ../trait.RngCore.html#tymethod.fill_bytes
322-
/// [`try_fill_bytes`]: ../trait.RngCore.html#tymethod.try_fill_bytes
323-
/// [`BlockRng`]: struct.BlockRng.html
311+
/// [`next_u32`]: RngCore::next_u32
312+
/// [`next_u64`]: RngCore::next_u64
313+
/// [`fill_bytes`]: RngCore::fill_bytes
314+
/// [`try_fill_bytes`]: RngCore::try_fill_bytes
324315
#[derive(Clone)]
325316
#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
326317
pub struct BlockRng64<R: BlockRngCore + ?Sized> {

rand_core/src/lib.rs

Lines changed: 32 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//! Random number generation traits
1111
//!
1212
//! This crate is mainly of interest to crates publishing implementations of
13-
//! [`RngCore`]. Other users are encouraged to use the [rand] crate instead
13+
//! [`RngCore`]. Other users are encouraged to use the [`rand`] crate instead
1414
//! which re-exports the main traits and error types.
1515
//!
1616
//! [`RngCore`] is the core trait implemented by algorithmic pseudo-random number
@@ -25,12 +25,7 @@
2525
//! The [`impls`] and [`le`] sub-modules include a few small functions to assist
2626
//! implementation of [`RngCore`].
2727
//!
28-
//! [rand]: https://crates.io/crates/rand
29-
//! [`RngCore`]: trait.RngCore.html
30-
//! [`SeedableRng`]: trait.SeedableRng.html
31-
//! [`Error`]: struct.Error.html
32-
//! [`impls`]: impls/index.html
33-
//! [`le`]: le/index.html
28+
//! [`rand`]: https://docs.rs/rand
3429
3530
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
3631
html_favicon_url = "https://www.rust-lang.org/favicon.ico",
@@ -68,8 +63,8 @@ pub mod le;
6863
///
6964
/// This trait encapsulates the low-level functionality common to all
7065
/// generators, and is the "back end", to be implemented by generators.
71-
/// End users should normally use [`Rng`] from the [rand] crate, which is
72-
/// automatically implemented for every type implementing `RngCore`.
66+
/// End users should normally use `Rng` trait from the [`rand`] crate,
67+
/// which is automatically implemented for every type implementing `RngCore`.
7368
///
7469
/// Three different methods for generating random data are provided since the
7570
/// optimal implementation of each is dependent on the type of generator. There
@@ -89,7 +84,7 @@ pub mod le;
8984
///
9085
/// Typically implementators will implement only one of the methods available
9186
/// in this trait directly, then use the helper functions from the
92-
/// [`rand_core::impls`] module to implement the other methods.
87+
/// [`impls`] module to implement the other methods.
9388
///
9489
/// It is recommended that implementations also implement:
9590
///
@@ -135,40 +130,37 @@ pub mod le;
135130
/// }
136131
/// ```
137132
///
138-
/// [rand]: https://crates.io/crates/rand
139-
/// [`Rng`]: ../rand/trait.Rng.html
140-
/// [`SeedableRng`]: trait.SeedableRng.html
141-
/// [`rand_core::impls`]: ../rand_core/impls/index.html
142-
/// [`try_fill_bytes`]: trait.RngCore.html#tymethod.try_fill_bytes
143-
/// [`fill_bytes`]: trait.RngCore.html#tymethod.fill_bytes
144-
/// [`next_u32`]: trait.RngCore.html#tymethod.next_u32
145-
/// [`next_u64`]: trait.RngCore.html#tymethod.next_u64
146-
/// [`CryptoRng`]: trait.CryptoRng.html
133+
/// [`rand`]: https://docs.rs/rand
134+
/// [`try_fill_bytes`]: RngCore::try_fill_bytes
135+
/// [`fill_bytes`]: RngCore::fill_bytes
136+
/// [`next_u32`]: RngCore::next_u32
137+
/// [`next_u64`]: RngCore::next_u64
147138
pub trait RngCore {
148139
/// Return the next random `u32`.
149140
///
150141
/// RNGs must implement at least one method from this trait directly. In
151142
/// the case this method is not implemented directly, it can be implemented
152-
/// using `self.next_u64() as u32` or
153-
/// [via `fill_bytes`](../rand_core/impls/fn.next_u32_via_fill.html).
143+
/// using `self.next_u64() as u32` or via
144+
/// [`fill_bytes`][impls::next_u32_via_fill].
154145
fn next_u32(&mut self) -> u32;
155146

156147
/// Return the next random `u64`.
157148
///
158149
/// RNGs must implement at least one method from this trait directly. In
159150
/// the case this method is not implemented directly, it can be implemented
160-
/// [via `next_u32`](../rand_core/impls/fn.next_u64_via_u32.html) or
161-
/// [via `fill_bytes`](../rand_core/impls/fn.next_u64_via_fill.html).
151+
/// via [`next_u32`][impls::next_u64_via_u32] or via
152+
/// [`fill_bytes`][impls::next_u64_via_fill].
162153
fn next_u64(&mut self) -> u64;
163154

164155
/// Fill `dest` with random data.
165156
///
166157
/// RNGs must implement at least one method from this trait directly. In
167158
/// the case this method is not implemented directly, it can be implemented
168-
/// [via `next_u*`](../rand_core/impls/fn.fill_bytes_via_next.html) or
169-
/// via `try_fill_bytes`; if this generator can fail the implementation
170-
/// must choose how best to handle errors here (e.g. panic with a
171-
/// descriptive message or log a warning and retry a few times).
159+
/// via [`next_u*`][impls::fill_bytes_via_next] or
160+
/// via [`try_fill_bytes`][RngCore::try_fill_bytes]; if this generator can
161+
/// fail the implementation must choose how best to handle errors here
162+
/// (e.g. panic with a descriptive message or log a warning and retry a few
163+
/// times).
172164
///
173165
/// This method should guarantee that `dest` is entirely filled
174166
/// with new data, and may panic if this is impossible
@@ -188,7 +180,7 @@ pub trait RngCore {
188180
/// `fill_bytes` may be implemented with
189181
/// `self.try_fill_bytes(dest).unwrap()` or more specific error handling.
190182
///
191-
/// [`fill_bytes`]: trait.RngCore.html#method.fill_bytes
183+
/// [`fill_bytes`]: RngCore::fill_bytes
192184
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>;
193185
}
194186

@@ -213,20 +205,19 @@ pub trait RngCore {
213205
/// Note also that use of a `CryptoRng` does not protect against other
214206
/// weaknesses such as seeding from a weak entropy source or leaking state.
215207
///
216-
/// [`RngCore`]: trait.RngCore.html
217-
/// [`BlockRngCore`]: ../rand_core/block/trait.BlockRngCore.html
208+
/// [`BlockRngCore`]: block::BlockRngCore
218209
pub trait CryptoRng {}
219210

220211
/// A random number generator that can be explicitly seeded.
221212
///
222213
/// This trait encapsulates the low-level functionality common to all
223214
/// pseudo-random number generators (PRNGs, or algorithmic generators).
224215
///
225-
/// The [`rand::FromEntropy`] trait is automatically implemented for every type
226-
/// implementing `SeedableRng`, providing a convenient `from_entropy()`
227-
/// constructor.
216+
/// The `FromEntropy` trait from [`rand`] crate is automatically
217+
/// implemented for every type implementing `SeedableRng`, providing
218+
/// a convenient `from_entropy()` constructor.
228219
///
229-
/// [`rand::FromEntropy`]: ../rand/trait.FromEntropy.html
220+
/// [`rand`]: https://docs.rs/rand
230221
pub trait SeedableRng: Sized {
231222
/// Seed type, which is restricted to types mutably-dereferencable as `u8`
232223
/// arrays (we recommend `[u8; N]` for some `N`).
@@ -340,8 +331,8 @@ pub trait SeedableRng: Sized {
340331
/// Create a new PRNG seeded from another `Rng`.
341332
///
342333
/// This is the recommended way to initialize PRNGs with fresh entropy. The
343-
/// [`FromEntropy`] trait provides a convenient `from_entropy` method
344-
/// based on `from_rng`.
334+
/// `FromEntropy` trait from [`rand`] crate provides a convenient
335+
/// `from_entropy` method based on `from_rng`.
345336
///
346337
/// Usage of this method is not recommended when reproducibility is required
347338
/// since implementing PRNGs are not required to fix Endianness and are
@@ -354,9 +345,9 @@ pub trait SeedableRng: Sized {
354345
/// results if their seed numbers are small or if there is a simple pattern
355346
/// between them.
356347
///
357-
/// Prefer to seed from a strong external entropy source like [`OsRng`] or
358-
/// from a cryptographic PRNG; if creating a new generator for cryptographic
359-
/// uses you *must* seed from a strong source.
348+
/// Prefer to seed from a strong external entropy source like `OsRng` from
349+
/// [`rand_os`] crate or from a cryptographic PRNG; if creating a new
350+
/// generator for cryptographic uses you *must* seed from a strong source.
360351
///
361352
/// Seeding a small PRNG from another small PRNG is possible, but
362353
/// something to be careful with. An extreme example of how this can go
@@ -367,8 +358,8 @@ pub trait SeedableRng: Sized {
367358
/// PRNG implementations are allowed to assume that a good RNG is provided
368359
/// for seeding, and that it is cryptographically secure when appropriate.
369360
///
370-
/// [`FromEntropy`]: ../rand/trait.FromEntropy.html
371-
/// [`OsRng`]: ../rand/rngs/struct.OsRng.html
361+
/// [`rand`]: https://docs.rs/rand
362+
/// [`rand_os`]: https://docs.rs/rand_os
372363
fn from_rng<R: RngCore>(mut rng: R) -> Result<Self, Error> {
373364
let mut seed = Self::Seed::default();
374365
rng.try_fill_bytes(seed.as_mut())?;

rand_hc/src/hc128.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ const SEED_WORDS: usize = 8; // 128 bit key followed by 128 bit iv
6363
///
6464
/// [^5]: Internet Engineering Task Force (February 2015),
6565
/// ["Prohibiting RC4 Cipher Suites"](https://tools.ietf.org/html/rfc7465).
66-
///
67-
/// [`BlockRng`]: ../rand_core/block/struct.BlockRng.html
68-
/// [`RngCore`]: ../rand_core/trait.RngCore.html
6966
#[derive(Clone, Debug)]
7067
pub struct Hc128Rng(BlockRng<Hc128Core>);
7168

rand_isaac/src/isaac.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ const RAND_SIZE: usize = 1 << RAND_SIZE_LEN;
3434
/// In spite of being designed with cryptographic security in mind, ISAAC hasn't
3535
/// been stringently cryptanalyzed and thus cryptographers do not not
3636
/// consensually trust it to be secure. When looking for a secure RNG, prefer
37-
/// [`Hc128Rng`] instead, which, like ISAAC, is an array-based RNG and one of
38-
/// the stream-ciphers selected the by eSTREAM contest.
37+
/// `Hc128Rng` from [`rand_hc`] crate instead, which, like ISAAC, is an
38+
/// array-based RNG and one of the stream-ciphers selected the by eSTREAM
3939
///
4040
/// In 2006 an improvement to ISAAC was suggested by Jean-Philippe Aumasson,
4141
/// named ISAAC+[^3]. But because the specification is not complete, because
@@ -86,9 +86,7 @@ const RAND_SIZE: usize = 1 << RAND_SIZE_LEN;
8686
/// [^3]: Jean-Philippe Aumasson, [*On the pseudo-random generator ISAAC*](
8787
/// https://eprint.iacr.org/2006/438)
8888
///
89-
/// [`Hc128Rng`]: ../../rand_hc/struct.Hc128Rng.html
90-
/// [`BlockRng`]: ../../rand_core/block/struct.BlockRng.html
91-
/// [`RngCore`]: ../../rand_core/trait.RngCore.html
89+
/// [`rand_hc`]: https://docs.rs/rand_hc
9290
#[derive(Clone, Debug)]
9391
#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
9492
pub struct IsaacRng(BlockRng<IsaacCore>);
@@ -142,7 +140,7 @@ impl IsaacRng {
142140
}
143141
}
144142

145-
/// The core of `IsaacRng`, used with `BlockRng`.
143+
/// The core of [`IsaacRng`], used with [`BlockRng`].
146144
#[derive(Clone)]
147145
#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
148146
pub struct IsaacCore {
@@ -165,7 +163,7 @@ impl BlockRngCore for IsaacCore {
165163
type Results = IsaacArray<Self::Item>;
166164

167165
/// Refills the output buffer, `results`. See also the pseudocode desciption
168-
/// of the algorithm in the [`IsaacRng`] documentation.
166+
/// of the algorithm in the `IsaacRng` documentation.
169167
///
170168
/// Optimisations used (similar to the reference implementation):
171169
///
@@ -183,8 +181,6 @@ impl BlockRngCore for IsaacCore {
183181
/// from `results` in reverse. We read them in the normal direction, to
184182
/// make `fill_bytes` a memcopy. To maintain compatibility we fill in
185183
/// reverse.
186-
///
187-
/// [`IsaacRng`]: struct.IsaacRng.html
188184
fn generate(&mut self, results: &mut IsaacArray<Self::Item>) {
189185
self.c += w(1);
190186
// abbreviations

rand_isaac/src/isaac64.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ const RAND_SIZE: usize = 1 << RAND_SIZE_LEN;
4040
/// In spite of being designed with cryptographic security in mind, ISAAC hasn't
4141
/// been stringently cryptanalyzed and thus cryptographers do not not
4242
/// consensually trust it to be secure. When looking for a secure RNG, prefer
43-
/// [`Hc128Rng`] instead, which, like ISAAC, is an array-based RNG and one of
44-
/// the stream-ciphers selected the by eSTREAM contest.
43+
/// `Hc128Rng` from [`rand_hc`] crate instead, which, like ISAAC, is an
44+
/// array-based RNG and one of the stream-ciphers selected the by eSTREAM
4545
///
4646
/// ## Overview of the ISAAC-64 algorithm:
4747
/// (in pseudo-code)
@@ -75,10 +75,9 @@ const RAND_SIZE: usize = 1 << RAND_SIZE_LEN;
7575
/// [^1]: Bob Jenkins, [*ISAAC and RC4*](
7676
/// http://burtleburtle.net/bob/rand/isaac.html)
7777
///
78-
/// [`IsaacRng`]: ../isaac/struct.IsaacRng.html
79-
/// [`Hc128Rng`]: ../../rand_hc/struct.Hc128Rng.html
80-
/// [`BlockRng64`]: ../../rand_core/block/struct.BlockRng64.html
81-
/// [`RngCore`]: ../../rand_core/trait.RngCore.html
78+
/// [`IsaacRng`]: crate::isaac::IsaacRng
79+
/// [`rand_hc`]: https://docs.rs/rand_hc
80+
/// [`BlockRng64`]: rand_core::block::BlockRng64
8281
#[derive(Clone, Debug)]
8382
#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
8483
pub struct Isaac64Rng(BlockRng64<Isaac64Core>);
@@ -155,7 +154,7 @@ impl BlockRngCore for Isaac64Core {
155154
type Results = IsaacArray<Self::Item>;
156155

157156
/// Refills the output buffer, `results`. See also the pseudocode desciption
158-
/// of the algorithm in the [`Isaac64Rng`] documentation.
157+
/// of the algorithm in the `Isaac64Rng` documentation.
159158
///
160159
/// Optimisations used (similar to the reference implementation):
161160
///
@@ -173,8 +172,6 @@ impl BlockRngCore for Isaac64Core {
173172
/// from `results` in reverse. We read them in the normal direction, to
174173
/// make `fill_bytes` a memcopy. To maintain compatibility we fill in
175174
/// reverse.
176-
///
177-
/// [`Isaac64Rng`]: struct.Isaac64Rng.html
178175
fn generate(&mut self, results: &mut IsaacArray<Self::Item>) {
179176
self.c += w(1);
180177
// abbreviations

rand_os/src/lib.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99

1010
//! Interface to the random number generator of the operating system.
1111
//!
12-
//! `OsRng` is the preferred external source of entropy for most applications.
12+
//! [`OsRng`] is the preferred external source of entropy for most applications.
1313
//! Commonly it is used to initialize a user-space RNG, which can then be used
1414
//! to generate random values with much less overhead than `OsRng`.
1515
//!
1616
//! You may prefer to use [`EntropyRng`] instead of `OsRng`. It is unlikely, but
1717
//! not entirely theoretical, for `OsRng` to fail. In such cases [`EntropyRng`]
1818
//! falls back on a good alternative entropy source.
1919
//!
20-
//! `OsRng::new()` is guaranteed to be very cheap (after the first successful
20+
//! [`OsRng::new()`] is guaranteed to be very cheap (after the first successful
2121
//! call), and will never consume more than one file handle per process.
2222
//!
2323
//! # Usage example
@@ -100,9 +100,8 @@
100100
//! but must eventually panic if the error persists.
101101
//!
102102
//! [`EntropyRng`]: ../rand/rngs/struct.EntropyRng.html
103-
//! [`RngCore`]: ../rand_core/trait.RngCore.html
104-
//! [`try_fill_bytes`]: ../rand_core/trait.RngCore.html#method.tymethod.try_fill_bytes
105-
//! [`ErrorKind::NotReady`]: ../rand_core/enum.ErrorKind.html#variant.NotReady
103+
//! [`try_fill_bytes`]: RngCore::try_fill_bytes
104+
//! [`ErrorKind::NotReady`]: rand_core::ErrorKind
106105
//!
107106
//! [1]: http://man7.org/linux/man-pages/man2/getrandom.2.html
108107
//! [2]: http://man7.org/linux/man-pages/man4/urandom.4.html

0 commit comments

Comments
 (0)