Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions library/core/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,9 @@ impl<T, const N: usize> [T; N] {
/// on large arrays or check the emitted code. Also try to avoid chained
/// maps (e.g. `arr.map(...).map(...)`).
///
/// In many cases, you can instead use [`Iterator::map`] by calling `.iter()`
/// or `.into_iter()` on your array. `[T; N]::map` is only necessary if you
/// really need a new array of the same size as the result. Rust's lazy
/// In many cases, you can instead use [`Iterator::map`] by calling [`.iter()`](slice::iter)
/// or [`.into_iter()`](IntoIterator::into_iter) on your array. `[T; N]::map` is only necessary
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we should be linking each of these methods -- it feels a little excessive. The documentation for into_iter/iter isn't anything special either, so users are likely to not gain too much from it.

/// if you really need a new array of the same size as the result. Rust's lazy
/// iterators tend to get optimized very well.
///
///
Expand Down Expand Up @@ -396,7 +396,7 @@ impl<T, const N: usize> [T; N] {
///
/// This method is particularly useful if combined with other methods, like
/// [`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)]
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#[lang = "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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Linking true seems a little excessive
  • I don't think we need to link Some or None, those are similarly to true basic vocabulary terms

///
/// # Examples
///
Expand All @@ -18,7 +18,7 @@ impl bool {
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
///
Expand Down
78 changes: 41 additions & 37 deletions library/core/src/char/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ impl char {
pub const REPLACEMENT_CHARACTER: char = '\u{FFFD}';

/// 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
/// 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.
///
/// The version numbering scheme is explained in
Expand All @@ -42,7 +42,7 @@ impl char {
pub const UNICODE_VERSION: (u8, u8, u8) = crate::unicode::UNICODE_VERSION;

/// 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
///
Expand Down Expand Up @@ -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};
Expand All @@ -93,10 +93,10 @@ impl char {
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
/// `as`:
/// [`as`](keyword.as.html):
///
/// ```
/// let c = '💯';
Expand All @@ -106,7 +106,7 @@ impl char {
/// ```
///
/// 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 an unsafe version of this function which ignores these checks, see
Expand All @@ -126,7 +126,7 @@ impl char {
/// 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;
Expand All @@ -141,7 +141,7 @@ impl char {
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
/// `as`:
Expand Down Expand Up @@ -190,7 +190,7 @@ impl char {
/// sixteen, hexadecimal, to give some common values. Arbitrary
/// 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.
///
/// # Panics
Expand All @@ -214,7 +214,7 @@ impl char {
/// 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;
Expand Down Expand Up @@ -299,7 +299,7 @@ impl char {
///
/// # 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
///
Expand Down Expand Up @@ -360,7 +360,7 @@ impl char {
/// println!();
/// ```
///
/// Using `println!` directly:
/// Using [`println!`](macro.println.html) directly:
///
/// ```
/// println!("{}", '❤'.escape_unicode());
Expand All @@ -372,7 +372,7 @@ impl char {
/// println!("\\u{{2764}}");
/// ```
///
/// Using `to_string`:
/// Using [`to_string`](string/trait.ToString.html#tymethod.to_string):
///
/// ```
/// assert_eq!('❤'.escape_unicode().to_string(), "\\u{2764}");
Expand Down Expand Up @@ -422,8 +422,8 @@ impl char {
/// Returns an iterator that yields the literal escape code of a character
/// as `char`s.
///
/// This will escape the characters similar to the `Debug` implementations
/// of `str` or `char`.
/// This will escape the characters similar to the [`Debug`](core::fmt::Debug) implementations
/// of [`str`] or `char`.
///
/// # Examples
///
Expand All @@ -436,7 +436,7 @@ impl char {
/// println!();
/// ```
///
/// Using `println!` directly:
/// Using [`println!`](macro.println.html) directly:
///
/// ```
/// println!("{}", '\n'.escape_debug());
Expand All @@ -448,7 +448,7 @@ impl char {
/// println!("\\n");
/// ```
///
/// Using `to_string`:
/// Using [`to_string`](string/trait.ToString.html#tymethod.to_string):
///
/// ```
/// assert_eq!('\n'.escape_debug().to_string(), "\\n");
Expand Down Expand Up @@ -490,7 +490,7 @@ impl char {
/// println!();
/// ```
///
/// Using `println!` directly:
/// Using [`println!`](macro.println.html) directly:
///
/// ```
/// println!("{}", '"'.escape_default());
Expand All @@ -502,7 +502,7 @@ impl char {
/// println!("\\\"");
/// ```
///
/// Using `to_string`:
/// Using [`to_string`](string/trait.ToString.html#tymethod.to_string):
///
/// ```
/// assert_eq!('"'.escape_default().to_string(), "\\\"");
Expand Down Expand Up @@ -543,8 +543,9 @@ impl char {
/// assert_eq!(len, 4);
/// ```
///
/// The `&str` type guarantees that its contents are UTF-8, and so we can compare the length it
/// would take if each code point was represented as a `char` vs in the `&str` itself:
/// The <code>[&](reference)[str]</code> type guarantees that its contents are UTF-8,
/// 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
Expand Down Expand Up @@ -637,7 +638,7 @@ impl char {
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.
///
/// # Panics
Expand All @@ -647,7 +648,7 @@ impl char {
///
/// # 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];
Expand All @@ -671,7 +672,7 @@ impl char {
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
/// specified in the [Unicode Character Database][ucd] [`DerivedCoreProperties.txt`].
Expand Down Expand Up @@ -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
/// specified in the [Unicode Character Database][ucd] [`DerivedCoreProperties.txt`].
Expand Down Expand Up @@ -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
/// specified in the [Unicode Character Database][ucd] [`DerivedCoreProperties.txt`].
Expand Down Expand Up @@ -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`].
///
Expand Down Expand Up @@ -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_numeric()`]: #method.is_numeric
Expand All @@ -818,7 +820,7 @@ impl char {
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
/// (Character Properties) of the [Unicode Standard] and specified in the [Unicode Character
Expand All @@ -843,7 +845,7 @@ impl char {
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
/// Segmentation)][uax29] and specified in the [Unicode Character Database][ucd]
Expand All @@ -857,7 +859,7 @@ impl char {
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
/// characters, and `No` for other numeric characters) are specified in the [Unicode Character
Expand Down Expand Up @@ -925,7 +927,7 @@ impl char {
/// println!();
/// ```
///
/// Using `println!` directly:
/// Using [`println!`](macro.println.html) directly:
///
/// ```
/// println!("{}", 'İ'.to_lowercase());
Expand All @@ -937,7 +939,7 @@ impl char {
/// 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");
Expand Down Expand Up @@ -990,7 +992,7 @@ impl char {
/// println!();
/// ```
///
/// Using `println!` directly:
/// Using [`println!`](macro.println.html) directly:
///
/// ```
/// println!("{}", 'ß'.to_uppercase());
Expand All @@ -1002,7 +1004,7 @@ impl char {
/// println!("SS");
/// ```
///
/// Using `to_string`:
/// Using [`to_string`](string/trait.ToString.html#tymethod.to_string):
///
/// ```
/// assert_eq!('c'.to_uppercase().to_string(), "C");
Expand Down Expand Up @@ -1131,7 +1133,7 @@ impl char {

/// 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
///
Expand All @@ -1144,6 +1146,8 @@ impl char {
/// assert!(upper_a.eq_ignore_ascii_case(&upper_a));
/// 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")]
#[rustc_const_stable(feature = "const_ascii_methods_on_intrinsics", since = "1.52.0")]
#[inline]
Expand Down
Loading