Add links in docs for some primitive types

This commit is contained in:
patrick-gu 2021-08-29 12:29:43 -07:00
parent 926f069950
commit 5719d22125
4 changed files with 85 additions and 72 deletions

View File

@ -310,9 +310,9 @@ impl<T, const N: usize> [T; N] {
/// on large arrays or check the emitted code. Also try to avoid chained /// on large arrays or check the emitted code. Also try to avoid chained
/// maps (e.g. `arr.map(...).map(...)`). /// maps (e.g. `arr.map(...).map(...)`).
/// ///
/// In many cases, you can instead use [`Iterator::map`] by calling `.iter()` /// In many cases, you can instead use [`Iterator::map`] by calling [`.iter()`](slice::iter)
/// or `.into_iter()` on your array. `[T; N]::map` is only necessary if you /// or [`.into_iter()`](IntoIterator::into_iter) on your array. `[T; N]::map` is only necessary
/// really need a new array of the same size as the result. Rust's lazy /// if you really need a new array of the same size as the result. Rust's lazy
/// iterators tend to get optimized very well. /// iterators tend to get optimized very well.
/// ///
/// ///
@ -396,7 +396,7 @@ impl<T, const N: usize> [T; N] {
/// ///
/// This method is particularly useful if combined with other methods, like /// This method is particularly useful if combined with other methods, like
/// [`map`](#method.map). This way, you can avoid moving the original /// [`map`](#method.map). This way, you can avoid moving the original
/// array if its elements are not `Copy`. /// array if its elements are not [`Copy`].
/// ///
/// ``` /// ```
/// #![feature(array_methods)] /// #![feature(array_methods)]

View File

@ -2,7 +2,7 @@
#[lang = "bool"] #[lang = "bool"]
impl bool { impl bool {
/// Returns `Some(t)` if the `bool` is `true`, or `None` otherwise. /// Returns <code>[Some]\(t)</code> if the `bool` is [`true`](keyword.true.html), or [`None`] otherwise.
/// ///
/// # Examples /// # Examples
/// ///
@ -18,7 +18,7 @@ impl bool {
if self { Some(t) } else { None } if self { Some(t) } else { None }
} }
/// Returns `Some(f())` if the `bool` is `true`, or `None` otherwise. /// Returns <code>[Some]\(f())</code> if the `bool` is [`true`](keyword.true.html), or [`None`] otherwise.
/// ///
/// # Examples /// # Examples
/// ///

View File

@ -29,11 +29,11 @@ impl char {
pub const REPLACEMENT_CHARACTER: char = '\u{FFFD}'; pub const REPLACEMENT_CHARACTER: char = '\u{FFFD}';
/// The version of [Unicode](https://www.unicode.org/) that the Unicode parts of /// The version of [Unicode](https://www.unicode.org/) that the Unicode parts of
/// `char` and `str` methods are based on. /// `char` and [`str`] methods are based on.
/// ///
/// New versions of Unicode are released regularly and subsequently all methods /// New versions of Unicode are released regularly and subsequently all methods
/// in the standard library depending on Unicode are updated. Therefore the /// in the standard library depending on Unicode are updated. Therefore the
/// behavior of some `char` and `str` methods and the value of this constant /// behavior of some `char` and [`str`] methods and the value of this constant
/// changes over time. This is *not* considered to be a breaking change. /// changes over time. This is *not* considered to be a breaking change.
/// ///
/// The version numbering scheme is explained in /// The version numbering scheme is explained in
@ -42,7 +42,7 @@ impl char {
pub const UNICODE_VERSION: (u8, u8, u8) = crate::unicode::UNICODE_VERSION; pub const UNICODE_VERSION: (u8, u8, u8) = crate::unicode::UNICODE_VERSION;
/// Creates an iterator over the UTF-16 encoded code points in `iter`, /// Creates an iterator over the UTF-16 encoded code points in `iter`,
/// returning unpaired surrogates as `Err`s. /// returning unpaired surrogates as [`Err`]s.
/// ///
/// # Examples /// # Examples
/// ///
@ -70,7 +70,7 @@ impl char {
/// ); /// );
/// ``` /// ```
/// ///
/// A lossy decoder can be obtained by replacing `Err` results with the replacement character: /// A lossy decoder can be obtained by replacing [`Err`] results with the replacement character:
/// ///
/// ``` /// ```
/// use std::char::{decode_utf16, REPLACEMENT_CHARACTER}; /// use std::char::{decode_utf16, REPLACEMENT_CHARACTER};
@ -93,10 +93,10 @@ impl char {
super::decode::decode_utf16(iter) super::decode::decode_utf16(iter)
} }
/// Converts a `u32` to a `char`. /// Converts a [`u32`] to a `char`.
/// ///
/// Note that all `char`s are valid [`u32`]s, and can be cast to one with /// Note that all `char`s are valid [`u32`]s, and can be cast to one with
/// `as`: /// [`as`](keyword.as.html):
/// ///
/// ``` /// ```
/// let c = '💯'; /// let c = '💯';
@ -106,7 +106,7 @@ impl char {
/// ``` /// ```
/// ///
/// However, the reverse is not true: not all valid [`u32`]s are valid /// However, the reverse is not true: not all valid [`u32`]s are valid
/// `char`s. `from_u32()` will return `None` if the input is not a valid value /// `char`s. `from_u32()` will return [`None`] if the input is not a valid value
/// for a `char`. /// for a `char`.
/// ///
/// For an unsafe version of this function which ignores these checks, see /// For an unsafe version of this function which ignores these checks, see
@ -126,7 +126,7 @@ impl char {
/// assert_eq!(Some('❤'), c); /// assert_eq!(Some('❤'), c);
/// ``` /// ```
/// ///
/// Returning `None` when the input is not a valid `char`: /// Returning [`None`] when the input is not a valid `char`:
/// ///
/// ``` /// ```
/// use std::char; /// use std::char;
@ -141,7 +141,7 @@ impl char {
super::convert::from_u32(i) super::convert::from_u32(i)
} }
/// Converts a `u32` to a `char`, ignoring validity. /// Converts a [`u32`] to a `char`, ignoring validity.
/// ///
/// Note that all `char`s are valid [`u32`]s, and can be cast to one with /// Note that all `char`s are valid [`u32`]s, and can be cast to one with
/// `as`: /// `as`:
@ -190,7 +190,7 @@ impl char {
/// sixteen, hexadecimal, to give some common values. Arbitrary /// sixteen, hexadecimal, to give some common values. Arbitrary
/// radices are supported. /// radices are supported.
/// ///
/// `from_digit()` will return `None` if the input is not a digit in /// `from_digit()` will return [`None`] if the input is not a digit in
/// the given radix. /// the given radix.
/// ///
/// # Panics /// # Panics
@ -214,7 +214,7 @@ impl char {
/// assert_eq!(Some('b'), c); /// assert_eq!(Some('b'), c);
/// ``` /// ```
/// ///
/// Returning `None` when the input is not a digit: /// Returning [`None`] when the input is not a digit:
/// ///
/// ``` /// ```
/// use std::char; /// use std::char;
@ -299,7 +299,7 @@ impl char {
/// ///
/// # Errors /// # Errors
/// ///
/// Returns `None` if the `char` does not refer to a digit in the given radix. /// Returns [`None`] if the `char` does not refer to a digit in the given radix.
/// ///
/// # Panics /// # Panics
/// ///
@ -360,7 +360,7 @@ impl char {
/// println!(); /// println!();
/// ``` /// ```
/// ///
/// Using `println!` directly: /// Using [`println!`](macro.println.html) directly:
/// ///
/// ``` /// ```
/// println!("{}", '❤'.escape_unicode()); /// println!("{}", '❤'.escape_unicode());
@ -372,7 +372,7 @@ impl char {
/// println!("\\u{{2764}}"); /// println!("\\u{{2764}}");
/// ``` /// ```
/// ///
/// Using `to_string`: /// Using [`to_string`](string/trait.ToString.html#tymethod.to_string):
/// ///
/// ``` /// ```
/// assert_eq!('❤'.escape_unicode().to_string(), "\\u{2764}"); /// assert_eq!('❤'.escape_unicode().to_string(), "\\u{2764}");
@ -422,8 +422,8 @@ impl char {
/// Returns an iterator that yields the literal escape code of a character /// Returns an iterator that yields the literal escape code of a character
/// as `char`s. /// as `char`s.
/// ///
/// This will escape the characters similar to the `Debug` implementations /// This will escape the characters similar to the [`Debug`](core::fmt::Debug) implementations
/// of `str` or `char`. /// of [`str`] or `char`.
/// ///
/// # Examples /// # Examples
/// ///
@ -436,7 +436,7 @@ impl char {
/// println!(); /// println!();
/// ``` /// ```
/// ///
/// Using `println!` directly: /// Using [`println!`](macro.println.html) directly:
/// ///
/// ``` /// ```
/// println!("{}", '\n'.escape_debug()); /// println!("{}", '\n'.escape_debug());
@ -448,7 +448,7 @@ impl char {
/// println!("\\n"); /// println!("\\n");
/// ``` /// ```
/// ///
/// Using `to_string`: /// Using [`to_string`](string/trait.ToString.html#tymethod.to_string):
/// ///
/// ``` /// ```
/// assert_eq!('\n'.escape_debug().to_string(), "\\n"); /// assert_eq!('\n'.escape_debug().to_string(), "\\n");
@ -490,7 +490,7 @@ impl char {
/// println!(); /// println!();
/// ``` /// ```
/// ///
/// Using `println!` directly: /// Using [`println!`](macro.println.html) directly:
/// ///
/// ``` /// ```
/// println!("{}", '"'.escape_default()); /// println!("{}", '"'.escape_default());
@ -502,7 +502,7 @@ impl char {
/// println!("\\\""); /// println!("\\\"");
/// ``` /// ```
/// ///
/// Using `to_string`: /// Using [`to_string`](string/trait.ToString.html#tymethod.to_string):
/// ///
/// ``` /// ```
/// assert_eq!('"'.escape_default().to_string(), "\\\""); /// assert_eq!('"'.escape_default().to_string(), "\\\"");
@ -543,8 +543,9 @@ impl char {
/// assert_eq!(len, 4); /// assert_eq!(len, 4);
/// ``` /// ```
/// ///
/// The `&str` type guarantees that its contents are UTF-8, and so we can compare the length it /// The <code>[&](reference)[str]</code> type guarantees that its contents are UTF-8,
/// would take if each code point was represented as a `char` vs in the `&str` itself: /// and so we can compare the length it would take if each code point was represented
/// as a `char` vs in the <code>[&](reference)[str]</code> itself:
/// ///
/// ``` /// ```
/// // as chars /// // as chars
@ -637,7 +638,7 @@ impl char {
unsafe { from_utf8_unchecked_mut(encode_utf8_raw(self as u32, dst)) } unsafe { from_utf8_unchecked_mut(encode_utf8_raw(self as u32, dst)) }
} }
/// Encodes this character as UTF-16 into the provided `u16` buffer, /// Encodes this character as UTF-16 into the provided [`u16`] buffer,
/// and then returns the subslice of the buffer that contains the encoded character. /// and then returns the subslice of the buffer that contains the encoded character.
/// ///
/// # Panics /// # Panics
@ -647,7 +648,7 @@ impl char {
/// ///
/// # Examples /// # Examples
/// ///
/// In both of these examples, '𝕊' takes two `u16`s to encode. /// In both of these examples, '𝕊' takes two [`u16`]s to encode.
/// ///
/// ``` /// ```
/// let mut b = [0; 2]; /// let mut b = [0; 2];
@ -671,7 +672,7 @@ impl char {
encode_utf16_raw(self as u32, dst) encode_utf16_raw(self as u32, dst)
} }
/// Returns `true` if this `char` has the `Alphabetic` property. /// Returns [`true`](keyword.true.html) if this `char` has the `Alphabetic` property.
/// ///
/// `Alphabetic` is described in Chapter 4 (Character Properties) of the [Unicode Standard] and /// `Alphabetic` is described in Chapter 4 (Character Properties) of the [Unicode Standard] and
/// specified in the [Unicode Character Database][ucd] [`DerivedCoreProperties.txt`]. /// specified in the [Unicode Character Database][ucd] [`DerivedCoreProperties.txt`].
@ -701,7 +702,7 @@ impl char {
} }
} }
/// Returns `true` if this `char` has the `Lowercase` property. /// Returns [`true`](keyword.true.html) if this `char` has the `Lowercase` property.
/// ///
/// `Lowercase` is described in Chapter 4 (Character Properties) of the [Unicode Standard] and /// `Lowercase` is described in Chapter 4 (Character Properties) of the [Unicode Standard] and
/// specified in the [Unicode Character Database][ucd] [`DerivedCoreProperties.txt`]. /// specified in the [Unicode Character Database][ucd] [`DerivedCoreProperties.txt`].
@ -733,7 +734,7 @@ impl char {
} }
} }
/// Returns `true` if this `char` has the `Uppercase` property. /// Returns [`true`](keyword.true.html) if this `char` has the `Uppercase` property.
/// ///
/// `Uppercase` is described in Chapter 4 (Character Properties) of the [Unicode Standard] and /// `Uppercase` is described in Chapter 4 (Character Properties) of the [Unicode Standard] and
/// specified in the [Unicode Character Database][ucd] [`DerivedCoreProperties.txt`]. /// specified in the [Unicode Character Database][ucd] [`DerivedCoreProperties.txt`].
@ -765,7 +766,7 @@ impl char {
} }
} }
/// Returns `true` if this `char` has the `White_Space` property. /// Returns [`true`](keyword.true.html) if this `char` has the `White_Space` property.
/// ///
/// `White_Space` is specified in the [Unicode Character Database][ucd] [`PropList.txt`]. /// `White_Space` is specified in the [Unicode Character Database][ucd] [`PropList.txt`].
/// ///
@ -793,7 +794,8 @@ impl char {
} }
} }
/// Returns `true` if this `char` satisfies either [`is_alphabetic()`] or [`is_numeric()`]. /// Returns [`true`](keyword.true.html) if this `char` satisfies either
/// [`is_alphabetic()`] or [`is_numeric()`].
/// ///
/// [`is_alphabetic()`]: #method.is_alphabetic /// [`is_alphabetic()`]: #method.is_alphabetic
/// [`is_numeric()`]: #method.is_numeric /// [`is_numeric()`]: #method.is_numeric
@ -818,7 +820,7 @@ impl char {
self.is_alphabetic() || self.is_numeric() self.is_alphabetic() || self.is_numeric()
} }
/// Returns `true` if this `char` has the general category for control codes. /// Returns [`true`](keyword.true.html) if this `char` has the general category for control codes.
/// ///
/// Control codes (code points with the general category of `Cc`) are described in Chapter 4 /// Control codes (code points with the general category of `Cc`) are described in Chapter 4
/// (Character Properties) of the [Unicode Standard] and specified in the [Unicode Character /// (Character Properties) of the [Unicode Standard] and specified in the [Unicode Character
@ -843,7 +845,7 @@ impl char {
unicode::Cc(self) unicode::Cc(self)
} }
/// Returns `true` if this `char` has the `Grapheme_Extend` property. /// Returns [`true`](keyword.true.html) if this `char` has the `Grapheme_Extend` property.
/// ///
/// `Grapheme_Extend` is described in [Unicode Standard Annex #29 (Unicode Text /// `Grapheme_Extend` is described in [Unicode Standard Annex #29 (Unicode Text
/// Segmentation)][uax29] and specified in the [Unicode Character Database][ucd] /// Segmentation)][uax29] and specified in the [Unicode Character Database][ucd]
@ -857,7 +859,7 @@ impl char {
unicode::Grapheme_Extend(self) unicode::Grapheme_Extend(self)
} }
/// Returns `true` if this `char` has one of the general categories for numbers. /// Returns [`true`](keyword.true.html) if this `char` has one of the general categories for numbers.
/// ///
/// The general categories for numbers (`Nd` for decimal digits, `Nl` for letter-like numeric /// The general categories for numbers (`Nd` for decimal digits, `Nl` for letter-like numeric
/// characters, and `No` for other numeric characters) are specified in the [Unicode Character /// characters, and `No` for other numeric characters) are specified in the [Unicode Character
@ -925,7 +927,7 @@ impl char {
/// println!(); /// println!();
/// ``` /// ```
/// ///
/// Using `println!` directly: /// Using [`println!`](macro.println.html) directly:
/// ///
/// ``` /// ```
/// println!("{}", 'İ'.to_lowercase()); /// println!("{}", 'İ'.to_lowercase());
@ -937,7 +939,7 @@ impl char {
/// println!("i\u{307}"); /// println!("i\u{307}");
/// ``` /// ```
/// ///
/// Using `to_string`: /// Using [`to_string`](string/trait.ToString.html#tymethod.to_string):
/// ///
/// ``` /// ```
/// assert_eq!('C'.to_lowercase().to_string(), "c"); /// assert_eq!('C'.to_lowercase().to_string(), "c");
@ -990,7 +992,7 @@ impl char {
/// println!(); /// println!();
/// ``` /// ```
/// ///
/// Using `println!` directly: /// Using [`println!`](macro.println.html) directly:
/// ///
/// ``` /// ```
/// println!("{}", 'ß'.to_uppercase()); /// println!("{}", 'ß'.to_uppercase());
@ -1002,7 +1004,7 @@ impl char {
/// println!("SS"); /// println!("SS");
/// ``` /// ```
/// ///
/// Using `to_string`: /// Using [`to_string`](string/trait.ToString.html#tymethod.to_string):
/// ///
/// ``` /// ```
/// assert_eq!('c'.to_uppercase().to_string(), "C"); /// assert_eq!('c'.to_uppercase().to_string(), "C");
@ -1131,7 +1133,7 @@ impl char {
/// Checks that two values are an ASCII case-insensitive match. /// Checks that two values are an ASCII case-insensitive match.
/// ///
/// Equivalent to `to_ascii_lowercase(a) == to_ascii_lowercase(b)`. /// Equivalent to <code>[to_ascii_lowercase]\(a) == [to_ascii_lowercase]\(b)</code>.
/// ///
/// # Examples /// # Examples
/// ///
@ -1144,6 +1146,8 @@ impl char {
/// assert!(upper_a.eq_ignore_ascii_case(&upper_a)); /// assert!(upper_a.eq_ignore_ascii_case(&upper_a));
/// assert!(!upper_a.eq_ignore_ascii_case(&lower_z)); /// assert!(!upper_a.eq_ignore_ascii_case(&lower_z));
/// ``` /// ```
///
/// [to_ascii_lowercase]: #method.to_ascii_lowercase
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[rustc_const_stable(feature = "const_ascii_methods_on_intrinsics", since = "1.52.0")] #[rustc_const_stable(feature = "const_ascii_methods_on_intrinsics", since = "1.52.0")]
#[inline] #[inline]

View File

@ -3,16 +3,16 @@
#[doc(alias = "false")] #[doc(alias = "false")]
/// The boolean type. /// The boolean type.
/// ///
/// The `bool` represents a value, which could only be either `true` or `false`. If you cast /// The `bool` represents a value, which could only be either [`true`] or [`false`]. If you cast
/// a `bool` into an integer, `true` will be 1 and `false` will be 0. /// a `bool` into an integer, [`true`] will be 1 and [`false`] will be 0.
/// ///
/// # Basic usage /// # Basic usage
/// ///
/// `bool` implements various traits, such as [`BitAnd`], [`BitOr`], [`Not`], etc., /// `bool` implements various traits, such as [`BitAnd`], [`BitOr`], [`Not`], etc.,
/// which allow us to perform boolean operations using `&`, `|` and `!`. /// which allow us to perform boolean operations using `&`, `|` and `!`.
/// ///
/// `if` requires a `bool` value as its conditional. [`assert!`], which is an /// [`if`] requires a `bool` value as its conditional. [`assert!`], which is an
/// important macro in testing, checks whether an expression is `true` and panics /// important macro in testing, checks whether an expression is [`true`] and panics
/// if it isn't. /// if it isn't.
/// ///
/// ``` /// ```
@ -20,9 +20,12 @@
/// assert!(!bool_val); /// assert!(!bool_val);
/// ``` /// ```
/// ///
/// [`true`]: keyword.true.html
/// [`false`]: keyword.false.html
/// [`BitAnd`]: ops::BitAnd /// [`BitAnd`]: ops::BitAnd
/// [`BitOr`]: ops::BitOr /// [`BitOr`]: ops::BitOr
/// [`Not`]: ops::Not /// [`Not`]: ops::Not
/// [`if`]: keyword.if.html
/// ///
/// # Examples /// # Examples
/// ///
@ -574,11 +577,11 @@ mod prim_pointer {}
/// ///
/// # Editions /// # Editions
/// ///
/// Prior to Rust 1.53, arrays did not implement `IntoIterator` by value, so the method call /// Prior to Rust 1.53, arrays did not implement [`IntoIterator`] by value, so the method call
/// `array.into_iter()` auto-referenced into a slice iterator. Right now, the old behavior /// <code>array.[into_iter()]</code> auto-referenced into a slice iterator.
/// is preserved in the 2015 and 2018 editions of Rust for compatibility, ignoring /// Right now, the old behavior is preserved in the 2015 and 2018 editions of Rust for
/// `IntoIterator` by value. In the future, the behavior on the 2015 and 2018 edition /// compatibility, ignoring [`IntoIterator`] by value. In the future, the behavior on the 2015 and
/// might be made consistent to the behavior of later editions. /// 2018 edition might be made consistent to the behavior of later editions.
/// ///
/// ```rust,edition2018 /// ```rust,edition2018
/// # #![allow(array_into_iter)] // override our `deny(warnings)` /// # #![allow(array_into_iter)] // override our `deny(warnings)`
@ -604,8 +607,9 @@ mod prim_pointer {}
/// } /// }
/// ``` /// ```
/// ///
/// Starting in the 2021 edition, `array.into_iter()` will use `IntoIterator` normally to iterate /// Starting in the 2021 edition, <code>array.[into_iter()]</code> will use [`IntoIterator`]
/// by value, and `iter()` should be used to iterate by reference like previous editions. /// normally to iterate by value, and [`iter()`](slice::iter) should be used to iterate by
/// reference like previous editions.
/// ///
/// ```rust,edition2021,ignore /// ```rust,edition2021,ignore
/// # // FIXME: ignored because 2021 testing is still unstable /// # // FIXME: ignored because 2021 testing is still unstable
@ -624,16 +628,16 @@ mod prim_pointer {}
/// } /// }
/// ``` /// ```
/// ///
/// Future language versions might start treating the `array.into_iter()` /// Future language versions might start treating the <code>array.[into_iter()]</code>
/// syntax on editions 2015 and 2018 the same as on edition 2021. So code using /// syntax on editions 2015 and 2018 the same as on edition 2021. So code using
/// those older editions should still be written with this change in mind, to /// those older editions should still be written with this change in mind, to
/// prevent breakage in the future. The safest way to accomplish this is to /// prevent breakage in the future. The safest way to accomplish this is to
/// avoid the `into_iter` syntax on those editions. If an edition update is not /// avoid the [`into_iter`](IntoIterator::into_iter) syntax on those editions.
/// viable/desired, there are multiple alternatives: /// If an edition update is not viable/desired, there are multiple alternatives:
/// * use `iter`, equivalent to the old behavior, creating references /// * use [`iter`](slice::iter), equivalent to the old behavior, creating references
/// * use [`array::IntoIter`], equivalent to the post-2021 behavior (Rust 1.51+) /// * use [`array::IntoIter`], equivalent to the post-2021 behavior (Rust 1.51+)
/// * replace `for ... in array.into_iter() {` with `for ... in array {`, /// * replace <code>[for] ... [in] array.[into_iter()] {</code>` with
/// equivalent to the post-2021 behavior (Rust 1.53+) /// <code>[for] ... [in] array {</code>, equivalent to the post-2021 behavior (Rust 1.53+)
/// ///
/// ```rust,edition2018 /// ```rust,edition2018
/// use std::array::IntoIter; /// use std::array::IntoIter;
@ -672,6 +676,9 @@ mod prim_pointer {}
/// [`Borrow`]: borrow::Borrow /// [`Borrow`]: borrow::Borrow
/// [`BorrowMut`]: borrow::BorrowMut /// [`BorrowMut`]: borrow::BorrowMut
/// [slice pattern]: ../reference/patterns.html#slice-patterns /// [slice pattern]: ../reference/patterns.html#slice-patterns
/// [into_iter()]: IntoIterator::into_iter
/// [for]: keyword.for.html
/// [in]: keyword.in.html
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
mod prim_array {} mod prim_array {}
@ -829,7 +836,7 @@ mod prim_str {}
/// ``` /// ```
/// ///
/// The sequential nature of the tuple applies to its implementations of various /// The sequential nature of the tuple applies to its implementations of various
/// traits. For example, in `PartialOrd` and `Ord`, the elements are compared /// traits. For example, in [`PartialOrd`] and [`Ord`], the elements are compared
/// sequentially until the first non-equal set is found. /// sequentially until the first non-equal set is found.
/// ///
/// For more about tuples, see [the book](../book/ch03-02-data-types.html#the-tuple-type). /// For more about tuples, see [the book](../book/ch03-02-data-types.html#the-tuple-type).
@ -1033,14 +1040,16 @@ mod prim_usize {}
/// References, both shared and mutable. /// References, both shared and mutable.
/// ///
/// A reference represents a borrow of some owned value. You can get one by using the `&` or `&mut` /// A reference represents a borrow of some owned value. You can get one by using the `&` or `&mut`
/// operators on a value, or by using a `ref` or `ref mut` pattern. /// operators on a value, or by using a [`ref`](keyword.ref.html) or
/// <code>[ref](keyword.ref.html) [mut](keyword.mut.html)</code> pattern.
/// ///
/// For those familiar with pointers, a reference is just a pointer that is assumed to be /// For those familiar with pointers, a reference is just a pointer that is assumed to be
/// aligned, not null, and pointing to memory containing a valid value of `T` - for example, /// aligned, not null, and pointing to memory containing a valid value of `T` - for example,
/// `&bool` can only point to an allocation containing the integer values `1` (`true`) or `0` /// <code>&[bool]</code> can only point to an allocation containing the integer values `1`
/// (`false`), but creating a `&bool` that points to an allocation containing /// ([`true`](keyword.true.html)) or `0` ([`false`](keyword.false.html)), but creating a
/// the value `3` causes undefined behaviour. /// <code>&[bool]</code> that points to an allocation containing the value `3` causes
/// In fact, `Option<&T>` has the same memory representation as a /// undefined behaviour.
/// In fact, <code>[Option]\<&T></code> has the same memory representation as a
/// nullable but aligned pointer, and can be passed across FFI boundaries as such. /// nullable but aligned pointer, and can be passed across FFI boundaries as such.
/// ///
/// In most cases, references can be used much like the original value. Field access, method /// In most cases, references can be used much like the original value. Field access, method
@ -1088,7 +1097,7 @@ mod prim_usize {}
/// The following traits are implemented for all `&T`, regardless of the type of its referent: /// The following traits are implemented for all `&T`, regardless of the type of its referent:
/// ///
/// * [`Copy`] /// * [`Copy`]
/// * [`Clone`] \(Note that this will not defer to `T`'s `Clone` implementation if it exists!) /// * [`Clone`] \(Note that this will not defer to `T`'s [`Clone`] implementation if it exists!)
/// * [`Deref`] /// * [`Deref`]
/// * [`Borrow`] /// * [`Borrow`]
/// * [`Pointer`] /// * [`Pointer`]
@ -1097,7 +1106,7 @@ mod prim_usize {}
/// [`Borrow`]: borrow::Borrow /// [`Borrow`]: borrow::Borrow
/// [`Pointer`]: fmt::Pointer /// [`Pointer`]: fmt::Pointer
/// ///
/// `&mut T` references get all of the above except `Copy` and `Clone` (to prevent creating /// `&mut T` references get all of the above except [`Copy`] and [`Clone`] (to prevent creating
/// multiple simultaneous mutable borrows), plus the following, regardless of the type of its /// multiple simultaneous mutable borrows), plus the following, regardless of the type of its
/// referent: /// referent:
/// ///
@ -1125,18 +1134,18 @@ mod prim_usize {}
/// [`Hash`]: hash::Hash /// [`Hash`]: hash::Hash
/// [`ToSocketAddrs`]: net::ToSocketAddrs /// [`ToSocketAddrs`]: net::ToSocketAddrs
/// ///
/// `&mut T` references get all of the above except `ToSocketAddrs`, plus the following, if `T` /// `&mut T` references get all of the above except [`ToSocketAddrs`], plus the following, if `T`
/// implements that trait: /// implements that trait:
/// ///
/// * [`AsMut`] /// * [`AsMut`]
/// * [`FnMut`] \(in addition, `&mut T` references get [`FnOnce`] if `T: FnMut`) /// * [`FnMut`] \(in addition, `&mut T` references get [`FnOnce`] if <code>T: [FnMut]</code>)
/// * [`fmt::Write`] /// * [`fmt::Write`]
/// * [`Iterator`] /// * [`Iterator`]
/// * [`DoubleEndedIterator`] /// * [`DoubleEndedIterator`]
/// * [`ExactSizeIterator`] /// * [`ExactSizeIterator`]
/// * [`FusedIterator`] /// * [`FusedIterator`]
/// * [`TrustedLen`] /// * [`TrustedLen`]
/// * [`Send`] \(note that `&T` references only get `Send` if `T: Sync`) /// * [`Send`] \(note that `&T` references only get [`Send`] if <code>T: [Sync]</code>)
/// * [`io::Write`] /// * [`io::Write`]
/// * [`Read`] /// * [`Read`]
/// * [`Seek`] /// * [`Seek`]
@ -1168,7 +1177,7 @@ mod prim_ref {}
/// Function pointers are pointers that point to *code*, not data. They can be called /// Function pointers are pointers that point to *code*, not data. They can be called
/// just like functions. Like references, function pointers are, among other things, assumed to /// just like functions. Like references, function pointers are, among other things, assumed to
/// not be null, so if you want to pass a function pointer over FFI and be able to accommodate null /// not be null, so if you want to pass a function pointer over FFI and be able to accommodate null
/// pointers, make your type `Option<fn()>` with your required signature. /// pointers, make your type <code>[Option]\<fn()></code> with your required signature.
/// ///
/// ### Safety /// ### Safety
/// ///