Skip to content

Commit 249dabe

Browse files
committed
Automatic linkification of Items
1 parent eff0fdc commit 249dabe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+1896
-862
lines changed

src/libcollections/binary_heap.rs

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
//!
2121
//! This is a larger example that implements [Dijkstra's algorithm][dijkstra]
2222
//! to solve the [shortest path problem][sssp] on a [directed graph][dir_graph].
23-
//! It shows how to use `BinaryHeap` with custom types.
23+
//! It shows how to use [`BinaryHeap`] with custom types.
2424
//!
2525
//! [dijkstra]: http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
2626
//! [sssp]: http://en.wikipedia.org/wiki/Shortest_path_problem
@@ -37,7 +37,7 @@
3737
//! position: usize,
3838
//! }
3939
//!
40-
//! // The priority queue depends on `Ord`.
40+
//! // The priority queue depends on [`Ord`].
4141
//! // Explicitly implement the trait so the queue becomes a min-heap
4242
//! // instead of a max-heap.
4343
//! impl Ord for State {
@@ -47,14 +47,14 @@
4747
//! }
4848
//! }
4949
//!
50-
//! // `PartialOrd` needs to be implemented as well.
50+
//! // [`PartialOrd`] needs to be implemented as well.
5151
//! impl PartialOrd for State {
5252
//! fn partial_cmp(&self, other: &State) -> Option<Ordering> {
5353
//! Some(self.cmp(other))
5454
//! }
5555
//! }
5656
//!
57-
//! // Each node is represented as an `usize`, for a shorter implementation.
57+
//! // Each node is represented as an [`usize`], for a shorter implementation.
5858
//! struct Edge {
5959
//! node: usize,
6060
//! cost: usize,
@@ -147,6 +147,11 @@
147147
//! assert_eq!(shortest_path(&graph, 4, 0), None);
148148
//! }
149149
//! ```
150+
//!
151+
//! [`BinaryHeap`]: /std/collections/binary_heap/struct.BinaryHeap.html
152+
//! [`Ord`]: /std/cmp/trait.Ord.html
153+
//! [`PartialOrd`]: /std/cmp/trait.PartialOrd.html
154+
//! [`usize`]: /std/primitive.usize.html
150155
151156
#![allow(missing_docs)]
152157
#![stable(feature = "rust1", since = "1.0.0")]
@@ -168,17 +173,17 @@ use super::SpecExtend;
168173
/// This will be a max-heap.
169174
///
170175
/// It is a logic error for an item to be modified in such a way that the
171-
/// item's ordering relative to any other item, as determined by the `Ord`
176+
/// item's ordering relative to any other item, as determined by the [`Ord`]
172177
/// trait, changes while it is in the heap. This is normally only possible
173-
/// through `Cell`, `RefCell`, global state, I/O, or unsafe code.
178+
/// through [`Cell`], [`RefCell`], global state, I/O, or unsafe code.
174179
///
175180
/// # Examples
176181
///
177182
/// ```
178183
/// use std::collections::BinaryHeap;
179184
///
180185
/// // Type inference lets us omit an explicit type signature (which
181-
/// // would be `BinaryHeap<i32>` in this example).
186+
/// // would be [`BinaryHeap<i32>`] in this example).
182187
/// let mut heap = BinaryHeap::new();
183188
///
184189
/// // We can use peek to look at the next item in the heap. In this case,
@@ -214,15 +219,21 @@ use super::SpecExtend;
214219
/// // The heap should now be empty.
215220
/// assert!(heap.is_empty())
216221
/// ```
222+
///
223+
/// [`BinaryHeap<i32>`]: /std/collections/binary_heap/struct.BinaryHeap.html
224+
/// [`Cell`]: /std/cell/struct.Cell.html
225+
/// [`Ord`]: /std/cmp/trait.Ord.html
226+
/// [`RefCell`]: /std/cell/struct.RefCell.html
217227
#[stable(feature = "rust1", since = "1.0.0")]
218228
pub struct BinaryHeap<T> {
219229
data: Vec<T>,
220230
}
221231

222232
/// A container object that represents the result of the [`peek_mut()`] method
223-
/// on `BinaryHeap`. See its documentation for details.
233+
/// on [`BinaryHeap`]. See its documentation for details.
224234
///
225235
/// [`peek_mut()`]: struct.BinaryHeap.html#method.peek_mut
236+
/// [`BinaryHeap`]: /std/collections/binary_heap/struct.BinaryHeap.html
226237
#[unstable(feature = "binary_heap_peek_mut", issue = "34392")]
227238
pub struct PeekMut<'a, T: 'a + Ord> {
228239
heap: &'a mut BinaryHeap<T>
@@ -945,7 +956,9 @@ impl<'a, T> Drop for Hole<'a, T> {
945956
}
946957
}
947958

948-
/// `BinaryHeap` iterator.
959+
/// [`BinaryHeap`] iterator.
960+
///
961+
/// [`BinaryHeap`]: /std/collections/binary_heap/struct.BinaryHeap.html
949962
#[stable(feature = "rust1", since = "1.0.0")]
950963
pub struct Iter<'a, T: 'a> {
951964
iter: slice::Iter<'a, T>,
@@ -985,7 +998,9 @@ impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
985998
#[stable(feature = "rust1", since = "1.0.0")]
986999
impl<'a, T> ExactSizeIterator for Iter<'a, T> {}
9871000

988-
/// An iterator that moves out of a `BinaryHeap`.
1001+
/// An iterator that moves out of a [`BinaryHeap`].
1002+
///
1003+
/// [`BinaryHeap`]: /std/collections/binary_heap/struct.BinaryHeap.html
9891004
#[stable(feature = "rust1", since = "1.0.0")]
9901005
#[derive(Clone)]
9911006
pub struct IntoIter<T> {
@@ -1018,7 +1033,9 @@ impl<T> DoubleEndedIterator for IntoIter<T> {
10181033
#[stable(feature = "rust1", since = "1.0.0")]
10191034
impl<T> ExactSizeIterator for IntoIter<T> {}
10201035

1021-
/// An iterator that drains a `BinaryHeap`.
1036+
/// An iterator that drains a [`BinaryHeap`].
1037+
///
1038+
/// [`BinaryHeap`]: /std/collections/binary_heap/struct.BinaryHeap.html
10221039
#[stable(feature = "drain", since = "1.6.0")]
10231040
pub struct Drain<'a, T: 'a> {
10241041
iter: vec::Drain<'a, T>,

src/libcollections/borrow.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,15 @@ impl<'a, B: ?Sized> Borrow<B> for Cow<'a, B>
3737
}
3838
}
3939

40-
/// A generalization of `Clone` to borrowed data.
40+
/// A generalization of [`Clone`] to borrowed data.
4141
///
4242
/// Some types make it possible to go from borrowed to owned, usually by
43-
/// implementing the `Clone` trait. But `Clone` works only for going from `&T`
44-
/// to `T`. The `ToOwned` trait generalizes `Clone` to construct owned data
43+
/// implementing the [`Clone`] trait. But [`Clone`] works only for going from `&T`
44+
/// to `T`. The [`ToOwned`] trait generalizes [`Clone`] to construct owned data
4545
/// from any borrow of a given type.
46+
///
47+
/// [`Clone`]: /std/clone/trait.Clone.html
48+
/// [`ToOwned`]: /std/borrow/trait.ToOwned.html
4649
#[stable(feature = "rust1", since = "1.0.0")]
4750
pub trait ToOwned {
4851
#[stable(feature = "rust1", since = "1.0.0")]
@@ -75,12 +78,12 @@ impl<T> ToOwned for T where T: Clone {
7578

7679
/// A clone-on-write smart pointer.
7780
///
78-
/// The type `Cow` is a smart pointer providing clone-on-write functionality: it
81+
/// The type [`Cow`] is a smart pointer providing clone-on-write functionality: it
7982
/// can enclose and provide immutable access to borrowed data, and clone the
8083
/// data lazily when mutation or ownership is required. The type is designed to
81-
/// work with general borrowed data via the `Borrow` trait.
84+
/// work with general borrowed data via the [`Borrow`] trait.
8285
///
83-
/// `Cow` implements `Deref`, which means that you can call
86+
/// [`Cow`] implements [`Deref`], which means that you can call
8487
/// non-mutating methods directly on the data it encloses. If mutation
8588
/// is desired, `to_mut` will obtain a mutable reference to an owned
8689
/// value, cloning if necessary.
@@ -101,6 +104,10 @@ impl<T> ToOwned for T where T: Clone {
101104
/// }
102105
/// }
103106
/// ```
107+
///
108+
/// [`Borrow`]: /std/borrow/trait.Borrow.html
109+
/// [`Cow`]: /std/borrow/enum.Cow.html
110+
/// [`Deref`]: /std/ops/trait.Deref.html
104111
#[stable(feature = "rust1", since = "1.0.0")]
105112
pub enum Cow<'a, B: ?Sized + 'a>
106113
where B: ToOwned

src/libcollections/btree/map.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,16 @@ use self::Entry::*;
5656
/// however, performance is excellent.
5757
///
5858
/// It is a logic error for a key to be modified in such a way that the key's ordering relative to
59-
/// any other key, as determined by the `Ord` trait, changes while it is in the map. This is
60-
/// normally only possible through `Cell`, `RefCell`, global state, I/O, or unsafe code.
59+
/// any other key, as determined by the [`Ord`] trait, changes while it is in the map. This is
60+
/// normally only possible through [`Cell`], [`RefCell`], global state, I/O, or unsafe code.
6161
///
6262
/// # Examples
6363
///
6464
/// ```
6565
/// use std::collections::BTreeMap;
6666
///
6767
/// // type inference lets us omit an explicit type signature (which
68-
/// // would be `BTreeMap<&str, &str>` in this example).
68+
/// // would be [`BTreeMap<&str, &str>`] in this example).
6969
/// let mut movie_reviews = BTreeMap::new();
7070
///
7171
/// // review some movies.
@@ -98,15 +98,15 @@ use self::Entry::*;
9898
/// }
9999
/// ```
100100
///
101-
/// `BTreeMap` also implements an [`Entry API`](#method.entry), which allows
101+
/// [`BTreeMap`] also implements an [`Entry API`](#method.entry), which allows
102102
/// for more complex methods of getting, setting, updating and removing keys and
103103
/// their values:
104104
///
105105
/// ```
106106
/// use std::collections::BTreeMap;
107107
///
108108
/// // type inference lets us omit an explicit type signature (which
109-
/// // would be `BTreeMap<&str, u8>` in this example).
109+
/// // would be [`BTreeMap<&str, u8>`] in this example).
110110
/// let mut player_stats = BTreeMap::new();
111111
///
112112
/// fn random_stat_buff() -> u8 {
@@ -126,6 +126,13 @@ use self::Entry::*;
126126
/// let stat = player_stats.entry("attack").or_insert(100);
127127
/// *stat += random_stat_buff();
128128
/// ```
129+
///
130+
/// [`BTreeMap`]: /std/collections/struct.BTreeMap.html
131+
/// [`BTreeMap<&str, &str>`]: /std/collections/struct.BTreeMap.html
132+
/// [`BTreeMap<&str, u8>`]: /std/collections/struct.BTreeMap.html
133+
/// [`Cell`]: /std/cell/struct.Cell.html
134+
/// [`Ord`]: /std/cmp/trait.Ord.html
135+
/// [`RefCell`]: /std/cell/struct.RefCell.html
129136
#[stable(feature = "rust1", since = "1.0.0")]
130137
pub struct BTreeMap<K, V> {
131138
root: node::Root<K, V>,

src/libcollections/btree/node.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,13 @@ impl<K, V> InternalNode<K, V> {
130130
}
131131
}
132132

133-
/// An owned pointer to a node. This basically is either `Box<LeafNode<K, V>>` or
134-
/// `Box<InternalNode<K, V>>`. However, it contains no information as to which of the two types
133+
/// An owned pointer to a node. This basically is either [`Box<LeafNode<K, V>>`] or
134+
/// [`Box<InternalNode<K, V>>`]. However, it contains no information as to which of the two types
135135
/// of nodes is acutally behind the box, and, partially due to this lack of information, has no
136136
/// destructor.
137+
///
138+
/// [`Box<InternalNode<K, V>>`]: /collections/boxed/struct.Box.html
139+
/// [`Box<LeafNode<K, V>>`]: /collections/boxed/struct.Box.html
137140
struct BoxedNode<K, V> {
138141
ptr: Unique<LeafNode<K, V>>
139142
}
@@ -274,12 +277,14 @@ impl<K, V> Root<K, V> {
274277
/// - `BorrowType`: This can be `Immut<'a>` or `Mut<'a>` for some `'a` or `Owned`.
275278
/// When this is `Immut<'a>`, the `NodeRef` acts roughly like `&'a Node`,
276279
/// when this is `Mut<'a>`, the `NodeRef` acts roughly like `&'a mut Node`,
277-
/// and when this is `Owned`, the `NodeRef` acts roughly like `Box<Node>`.
280+
/// and when this is `Owned`, the `NodeRef` acts roughly like [`Box<Node>`].
278281
/// - `K` and `V`: These control what types of things are stored in the nodes.
279282
/// - `Type`: This can be `Leaf`, `Internal`, or `LeafOrInternal`. When this is
280283
/// `Leaf`, the `NodeRef` points to a leaf node, when this is `Internal` the
281284
/// `NodeRef` points to an internal node, and when this is `LeafOrInternal` the
282285
/// `NodeRef` could be pointing to either type of node.
286+
///
287+
/// [`Box<Node>`]: /collections/boxed/struct.Box.html
283288
pub struct NodeRef<BorrowType, K, V, Type> {
284289
height: usize,
285290
node: NonZero<*const LeafNode<K, V>>,

src/libcollections/btree/set.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use Bound;
4545
/// use std::collections::BTreeSet;
4646
///
4747
/// // Type inference lets us omit an explicit type signature (which
48-
/// // would be `BTreeSet<&str>` in this example).
48+
/// // would be [`BTreeSet<&str>`] in this example).
4949
/// let mut books = BTreeSet::new();
5050
///
5151
/// // Add some books.
@@ -68,6 +68,8 @@ use Bound;
6868
/// println!("{}", book);
6969
/// }
7070
/// ```
71+
///
72+
/// [`BTreeSet<&str>`]: /std/collections/btree_set/struct.BTreeSet.html
7173
#[derive(Clone, Hash, PartialEq, Eq, Ord, PartialOrd)]
7274
#[stable(feature = "rust1", since = "1.0.0")]
7375
pub struct BTreeSet<T> {

src/libcollections/enum_set.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,14 @@ use core::ops::{Sub, BitOr, BitAnd, BitXor};
2929
/// A specialized set implementation to use enum types.
3030
///
3131
/// It is a logic error for an item to be modified in such a way that the
32-
/// transformation of the item to or from a `usize`, as determined by the
33-
/// `CLike` trait, changes while the item is in the set. This is normally only
34-
/// possible through `Cell`, `RefCell`, global state, I/O, or unsafe code.
32+
/// transformation of the item to or from a [`usize`], as determined by the
33+
/// [`CLike`] trait, changes while the item is in the set. This is normally only
34+
/// possible through [`Cell`], [`RefCell`], global state, I/O, or unsafe code.
35+
///
36+
/// [`CLike`]: /collections/enum_set/trait.CLike.html
37+
/// [`Cell`]: /std/cell/struct.Cell.html
38+
/// [`RefCell`]: /std/cell/struct.RefCell.html
39+
/// [`usize`]: /std/primitive.usize.html
3540
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)]
3641
pub struct EnumSet<E> {
3742
// We must maintain the invariant that no bits are set

0 commit comments

Comments
 (0)