Skip to content

Commit 5719d22

Browse files
committed
Add links in docs for some primitive types
1 parent 926f069 commit 5719d22

File tree

4 files changed

+85
-72
lines changed

4 files changed

+85
-72
lines changed

library/core/src/array/mod.rs

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

library/core/src/bool.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
#[lang = "bool"]
44
impl bool {
5-
/// Returns `Some(t)` if the `bool` is `true`, or `None` otherwise.
5+
/// Returns <code>[Some]\(t)</code> if the `bool` is [`true`](keyword.true.html), or [`None`] otherwise.
66
///
77
/// # Examples
88
///
@@ -18,7 +18,7 @@ impl bool {
1818
if self { Some(t) } else { None }
1919
}
2020

21-
/// Returns `Some(f())` if the `bool` is `true`, or `None` otherwise.
21+
/// Returns <code>[Some]\(f())</code> if the `bool` is [`true`](keyword.true.html), or [`None`] otherwise.
2222
///
2323
/// # Examples
2424
///

library/core/src/char/methods.rs

+41-37
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ impl char {
2929
pub const REPLACEMENT_CHARACTER: char = '\u{FFFD}';
3030

3131
/// The version of [Unicode](https://www.unicode.org/) that the Unicode parts of
32-
/// `char` and `str` methods are based on.
32+
/// `char` and [`str`] methods are based on.
3333
///
3434
/// New versions of Unicode are released regularly and subsequently all methods
3535
/// in the standard library depending on Unicode are updated. Therefore the
36-
/// behavior of some `char` and `str` methods and the value of this constant
36+
/// behavior of some `char` and [`str`] methods and the value of this constant
3737
/// changes over time. This is *not* considered to be a breaking change.
3838
///
3939
/// The version numbering scheme is explained in
@@ -42,7 +42,7 @@ impl char {
4242
pub const UNICODE_VERSION: (u8, u8, u8) = crate::unicode::UNICODE_VERSION;
4343

4444
/// Creates an iterator over the UTF-16 encoded code points in `iter`,
45-
/// returning unpaired surrogates as `Err`s.
45+
/// returning unpaired surrogates as [`Err`]s.
4646
///
4747
/// # Examples
4848
///
@@ -70,7 +70,7 @@ impl char {
7070
/// );
7171
/// ```
7272
///
73-
/// A lossy decoder can be obtained by replacing `Err` results with the replacement character:
73+
/// A lossy decoder can be obtained by replacing [`Err`] results with the replacement character:
7474
///
7575
/// ```
7676
/// use std::char::{decode_utf16, REPLACEMENT_CHARACTER};
@@ -93,10 +93,10 @@ impl char {
9393
super::decode::decode_utf16(iter)
9494
}
9595

96-
/// Converts a `u32` to a `char`.
96+
/// Converts a [`u32`] to a `char`.
9797
///
9898
/// Note that all `char`s are valid [`u32`]s, and can be cast to one with
99-
/// `as`:
99+
/// [`as`](keyword.as.html):
100100
///
101101
/// ```
102102
/// let c = '💯';
@@ -106,7 +106,7 @@ impl char {
106106
/// ```
107107
///
108108
/// However, the reverse is not true: not all valid [`u32`]s are valid
109-
/// `char`s. `from_u32()` will return `None` if the input is not a valid value
109+
/// `char`s. `from_u32()` will return [`None`] if the input is not a valid value
110110
/// for a `char`.
111111
///
112112
/// For an unsafe version of this function which ignores these checks, see
@@ -126,7 +126,7 @@ impl char {
126126
/// assert_eq!(Some('❤'), c);
127127
/// ```
128128
///
129-
/// Returning `None` when the input is not a valid `char`:
129+
/// Returning [`None`] when the input is not a valid `char`:
130130
///
131131
/// ```
132132
/// use std::char;
@@ -141,7 +141,7 @@ impl char {
141141
super::convert::from_u32(i)
142142
}
143143

144-
/// Converts a `u32` to a `char`, ignoring validity.
144+
/// Converts a [`u32`] to a `char`, ignoring validity.
145145
///
146146
/// Note that all `char`s are valid [`u32`]s, and can be cast to one with
147147
/// `as`:
@@ -190,7 +190,7 @@ impl char {
190190
/// sixteen, hexadecimal, to give some common values. Arbitrary
191191
/// radices are supported.
192192
///
193-
/// `from_digit()` will return `None` if the input is not a digit in
193+
/// `from_digit()` will return [`None`] if the input is not a digit in
194194
/// the given radix.
195195
///
196196
/// # Panics
@@ -214,7 +214,7 @@ impl char {
214214
/// assert_eq!(Some('b'), c);
215215
/// ```
216216
///
217-
/// Returning `None` when the input is not a digit:
217+
/// Returning [`None`] when the input is not a digit:
218218
///
219219
/// ```
220220
/// use std::char;
@@ -299,7 +299,7 @@ impl char {
299299
///
300300
/// # Errors
301301
///
302-
/// Returns `None` if the `char` does not refer to a digit in the given radix.
302+
/// Returns [`None`] if the `char` does not refer to a digit in the given radix.
303303
///
304304
/// # Panics
305305
///
@@ -360,7 +360,7 @@ impl char {
360360
/// println!();
361361
/// ```
362362
///
363-
/// Using `println!` directly:
363+
/// Using [`println!`](macro.println.html) directly:
364364
///
365365
/// ```
366366
/// println!("{}", '❤'.escape_unicode());
@@ -372,7 +372,7 @@ impl char {
372372
/// println!("\\u{{2764}}");
373373
/// ```
374374
///
375-
/// Using `to_string`:
375+
/// Using [`to_string`](string/trait.ToString.html#tymethod.to_string):
376376
///
377377
/// ```
378378
/// assert_eq!('❤'.escape_unicode().to_string(), "\\u{2764}");
@@ -422,8 +422,8 @@ impl char {
422422
/// Returns an iterator that yields the literal escape code of a character
423423
/// as `char`s.
424424
///
425-
/// This will escape the characters similar to the `Debug` implementations
426-
/// of `str` or `char`.
425+
/// This will escape the characters similar to the [`Debug`](core::fmt::Debug) implementations
426+
/// of [`str`] or `char`.
427427
///
428428
/// # Examples
429429
///
@@ -436,7 +436,7 @@ impl char {
436436
/// println!();
437437
/// ```
438438
///
439-
/// Using `println!` directly:
439+
/// Using [`println!`](macro.println.html) directly:
440440
///
441441
/// ```
442442
/// println!("{}", '\n'.escape_debug());
@@ -448,7 +448,7 @@ impl char {
448448
/// println!("\\n");
449449
/// ```
450450
///
451-
/// Using `to_string`:
451+
/// Using [`to_string`](string/trait.ToString.html#tymethod.to_string):
452452
///
453453
/// ```
454454
/// assert_eq!('\n'.escape_debug().to_string(), "\\n");
@@ -490,7 +490,7 @@ impl char {
490490
/// println!();
491491
/// ```
492492
///
493-
/// Using `println!` directly:
493+
/// Using [`println!`](macro.println.html) directly:
494494
///
495495
/// ```
496496
/// println!("{}", '"'.escape_default());
@@ -502,7 +502,7 @@ impl char {
502502
/// println!("\\\"");
503503
/// ```
504504
///
505-
/// Using `to_string`:
505+
/// Using [`to_string`](string/trait.ToString.html#tymethod.to_string):
506506
///
507507
/// ```
508508
/// assert_eq!('"'.escape_default().to_string(), "\\\"");
@@ -543,8 +543,9 @@ impl char {
543543
/// assert_eq!(len, 4);
544544
/// ```
545545
///
546-
/// The `&str` type guarantees that its contents are UTF-8, and so we can compare the length it
547-
/// would take if each code point was represented as a `char` vs in the `&str` itself:
546+
/// The <code>[&](reference)[str]</code> type guarantees that its contents are UTF-8,
547+
/// and so we can compare the length it would take if each code point was represented
548+
/// as a `char` vs in the <code>[&](reference)[str]</code> itself:
548549
///
549550
/// ```
550551
/// // as chars
@@ -637,7 +638,7 @@ impl char {
637638
unsafe { from_utf8_unchecked_mut(encode_utf8_raw(self as u32, dst)) }
638639
}
639640

640-
/// Encodes this character as UTF-16 into the provided `u16` buffer,
641+
/// Encodes this character as UTF-16 into the provided [`u16`] buffer,
641642
/// and then returns the subslice of the buffer that contains the encoded character.
642643
///
643644
/// # Panics
@@ -647,7 +648,7 @@ impl char {
647648
///
648649
/// # Examples
649650
///
650-
/// In both of these examples, '𝕊' takes two `u16`s to encode.
651+
/// In both of these examples, '𝕊' takes two [`u16`]s to encode.
651652
///
652653
/// ```
653654
/// let mut b = [0; 2];
@@ -671,7 +672,7 @@ impl char {
671672
encode_utf16_raw(self as u32, dst)
672673
}
673674

674-
/// Returns `true` if this `char` has the `Alphabetic` property.
675+
/// Returns [`true`](keyword.true.html) if this `char` has the `Alphabetic` property.
675676
///
676677
/// `Alphabetic` is described in Chapter 4 (Character Properties) of the [Unicode Standard] and
677678
/// specified in the [Unicode Character Database][ucd] [`DerivedCoreProperties.txt`].
@@ -701,7 +702,7 @@ impl char {
701702
}
702703
}
703704

704-
/// Returns `true` if this `char` has the `Lowercase` property.
705+
/// Returns [`true`](keyword.true.html) if this `char` has the `Lowercase` property.
705706
///
706707
/// `Lowercase` is described in Chapter 4 (Character Properties) of the [Unicode Standard] and
707708
/// specified in the [Unicode Character Database][ucd] [`DerivedCoreProperties.txt`].
@@ -733,7 +734,7 @@ impl char {
733734
}
734735
}
735736

736-
/// Returns `true` if this `char` has the `Uppercase` property.
737+
/// Returns [`true`](keyword.true.html) if this `char` has the `Uppercase` property.
737738
///
738739
/// `Uppercase` is described in Chapter 4 (Character Properties) of the [Unicode Standard] and
739740
/// specified in the [Unicode Character Database][ucd] [`DerivedCoreProperties.txt`].
@@ -765,7 +766,7 @@ impl char {
765766
}
766767
}
767768

768-
/// Returns `true` if this `char` has the `White_Space` property.
769+
/// Returns [`true`](keyword.true.html) if this `char` has the `White_Space` property.
769770
///
770771
/// `White_Space` is specified in the [Unicode Character Database][ucd] [`PropList.txt`].
771772
///
@@ -793,7 +794,8 @@ impl char {
793794
}
794795
}
795796

796-
/// Returns `true` if this `char` satisfies either [`is_alphabetic()`] or [`is_numeric()`].
797+
/// Returns [`true`](keyword.true.html) if this `char` satisfies either
798+
/// [`is_alphabetic()`] or [`is_numeric()`].
797799
///
798800
/// [`is_alphabetic()`]: #method.is_alphabetic
799801
/// [`is_numeric()`]: #method.is_numeric
@@ -818,7 +820,7 @@ impl char {
818820
self.is_alphabetic() || self.is_numeric()
819821
}
820822

821-
/// Returns `true` if this `char` has the general category for control codes.
823+
/// Returns [`true`](keyword.true.html) if this `char` has the general category for control codes.
822824
///
823825
/// Control codes (code points with the general category of `Cc`) are described in Chapter 4
824826
/// (Character Properties) of the [Unicode Standard] and specified in the [Unicode Character
@@ -843,7 +845,7 @@ impl char {
843845
unicode::Cc(self)
844846
}
845847

846-
/// Returns `true` if this `char` has the `Grapheme_Extend` property.
848+
/// Returns [`true`](keyword.true.html) if this `char` has the `Grapheme_Extend` property.
847849
///
848850
/// `Grapheme_Extend` is described in [Unicode Standard Annex #29 (Unicode Text
849851
/// Segmentation)][uax29] and specified in the [Unicode Character Database][ucd]
@@ -857,7 +859,7 @@ impl char {
857859
unicode::Grapheme_Extend(self)
858860
}
859861

860-
/// Returns `true` if this `char` has one of the general categories for numbers.
862+
/// Returns [`true`](keyword.true.html) if this `char` has one of the general categories for numbers.
861863
///
862864
/// The general categories for numbers (`Nd` for decimal digits, `Nl` for letter-like numeric
863865
/// characters, and `No` for other numeric characters) are specified in the [Unicode Character
@@ -925,7 +927,7 @@ impl char {
925927
/// println!();
926928
/// ```
927929
///
928-
/// Using `println!` directly:
930+
/// Using [`println!`](macro.println.html) directly:
929931
///
930932
/// ```
931933
/// println!("{}", 'İ'.to_lowercase());
@@ -937,7 +939,7 @@ impl char {
937939
/// println!("i\u{307}");
938940
/// ```
939941
///
940-
/// Using `to_string`:
942+
/// Using [`to_string`](string/trait.ToString.html#tymethod.to_string):
941943
///
942944
/// ```
943945
/// assert_eq!('C'.to_lowercase().to_string(), "c");
@@ -990,7 +992,7 @@ impl char {
990992
/// println!();
991993
/// ```
992994
///
993-
/// Using `println!` directly:
995+
/// Using [`println!`](macro.println.html) directly:
994996
///
995997
/// ```
996998
/// println!("{}", 'ß'.to_uppercase());
@@ -1002,7 +1004,7 @@ impl char {
10021004
/// println!("SS");
10031005
/// ```
10041006
///
1005-
/// Using `to_string`:
1007+
/// Using [`to_string`](string/trait.ToString.html#tymethod.to_string):
10061008
///
10071009
/// ```
10081010
/// assert_eq!('c'.to_uppercase().to_string(), "C");
@@ -1131,7 +1133,7 @@ impl char {
11311133

11321134
/// Checks that two values are an ASCII case-insensitive match.
11331135
///
1134-
/// Equivalent to `to_ascii_lowercase(a) == to_ascii_lowercase(b)`.
1136+
/// Equivalent to <code>[to_ascii_lowercase]\(a) == [to_ascii_lowercase]\(b)</code>.
11351137
///
11361138
/// # Examples
11371139
///
@@ -1144,6 +1146,8 @@ impl char {
11441146
/// assert!(upper_a.eq_ignore_ascii_case(&upper_a));
11451147
/// assert!(!upper_a.eq_ignore_ascii_case(&lower_z));
11461148
/// ```
1149+
///
1150+
/// [to_ascii_lowercase]: #method.to_ascii_lowercase
11471151
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
11481152
#[rustc_const_stable(feature = "const_ascii_methods_on_intrinsics", since = "1.52.0")]
11491153
#[inline]

0 commit comments

Comments
 (0)