Skip to content

Commit 5cec065

Browse files
Add missing urls for ops module
1 parent dcc8d57 commit 5cec065

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

src/libcore/ops.rs

+19-15
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//!
1515
//! Some of these traits are imported by the prelude, so they are available in
1616
//! every Rust program. Only operators backed by traits can be overloaded. For
17-
//! example, the addition operator (`+`) can be overloaded through the `Add`
17+
//! example, the addition operator (`+`) can be overloaded through the [`Add`]
1818
//! trait, but since the assignment operator (`=`) has no backing trait, there
1919
//! is no way of overloading its semantics. Additionally, this module does not
2020
//! provide any mechanism to create new operators. If traitless overloading or
@@ -30,17 +30,18 @@
3030
//! contexts involving built-in types, this is usually not a problem.
3131
//! However, using these operators in generic code, requires some
3232
//! attention if values have to be reused as opposed to letting the operators
33-
//! consume them. One option is to occasionally use `clone()`.
33+
//! consume them. One option is to occasionally use [`clone()`].
3434
//! Another option is to rely on the types involved providing additional
3535
//! operator implementations for references. For example, for a user-defined
3636
//! type `T` which is supposed to support addition, it is probably a good
37-
//! idea to have both `T` and `&T` implement the traits `Add<T>` and `Add<&T>`
38-
//! so that generic code can be written without unnecessary cloning.
37+
//! idea to have both `T` and `&T` implement the traits [`Add<T>`][`Add`] and
38+
//! [`Add<&T>`][`Add`] so that generic code can be written without unnecessary
39+
//! cloning.
3940
//!
4041
//! # Examples
4142
//!
42-
//! This example creates a `Point` struct that implements `Add` and `Sub`, and
43-
//! then demonstrates adding and subtracting two `Point`s.
43+
//! This example creates a `Point` struct that implements [`Add`] and [`Sub`],
44+
//! and then demonstrates adding and subtracting two `Point`s.
4445
//!
4546
//! ```rust
4647
//! use std::ops::{Add, Sub};
@@ -75,18 +76,14 @@
7576
//! See the documentation for each trait for an example implementation.
7677
//!
7778
//! The [`Fn`], [`FnMut`], and [`FnOnce`] traits are implemented by types that can be
78-
//! invoked like functions. Note that `Fn` takes `&self`, `FnMut` takes `&mut
79-
//! self` and `FnOnce` takes `self`. These correspond to the three kinds of
79+
//! invoked like functions. Note that [`Fn`] takes `&self`, [`FnMut`] takes `&mut
80+
//! self` and [`FnOnce`] takes `self`. These correspond to the three kinds of
8081
//! methods that can be invoked on an instance: call-by-reference,
8182
//! call-by-mutable-reference, and call-by-value. The most common use of these
8283
//! traits is to act as bounds to higher-level functions that take functions or
8384
//! closures as arguments.
8485
//!
85-
//! [`Fn`]: trait.Fn.html
86-
//! [`FnMut`]: trait.FnMut.html
87-
//! [`FnOnce`]: trait.FnOnce.html
88-
//!
89-
//! Taking a `Fn` as a parameter:
86+
//! Taking a [`Fn`] as a parameter:
9087
//!
9188
//! ```rust
9289
//! fn call_with_one<F>(func: F) -> usize
@@ -99,7 +96,7 @@
9996
//! assert_eq!(call_with_one(double), 2);
10097
//! ```
10198
//!
102-
//! Taking a `FnMut` as a parameter:
99+
//! Taking a [`FnMut`] as a parameter:
103100
//!
104101
//! ```rust
105102
//! fn do_twice<F>(mut func: F)
@@ -118,7 +115,7 @@
118115
//! assert_eq!(x, 5);
119116
//! ```
120117
//!
121-
//! Taking a `FnOnce` as a parameter:
118+
//! Taking a [`FnOnce`] as a parameter:
122119
//!
123120
//! ```rust
124121
//! fn consume_with_relish<F>(func: F)
@@ -140,6 +137,13 @@
140137
//!
141138
//! // `consume_and_return_x` can no longer be invoked at this point
142139
//! ```
140+
//!
141+
//! [`Fn`]: trait.Fn.html
142+
//! [`FnMut`]: trait.FnMut.html
143+
//! [`FnOnce`]: trait.FnOnce.html
144+
//! [`Add`]: trait.Add.html
145+
//! [`Sub`]: trait.Sub.html
146+
//! [`clone()`]: ../clone/trait.Clone.html#tymethod.clone
143147
144148
#![stable(feature = "rust1", since = "1.0.0")]
145149

0 commit comments

Comments
 (0)