diff options
| author | patrick-gu <55641350+patrick-gu@users.noreply.github.com> | 2021-08-29 12:29:43 -0700 |
|---|---|---|
| committer | patrick-gu <55641350+patrick-gu@users.noreply.github.com> | 2021-08-29 13:48:21 -0700 |
| commit | 5719d221252e5b541dfc3d6d6557f73875fc76b4 (patch) | |
| tree | 72efc49a453fe215a98f01f31b9fa04b4ec0930d /library/core/src/char | |
| parent | 926f069950d7211a87fbd81778b420de420daad7 (diff) | |
Add links in docs for some primitive types
Diffstat (limited to 'library/core/src/char')
| -rw-r--r-- | library/core/src/char/methods.rs | 78 |
1 files changed, 41 insertions, 37 deletions
diff --git a/library/core/src/char/methods.rs b/library/core/src/char/methods.rs index 0dadbdd1bd0..46ceef13b15 100644 --- a/library/core/src/char/methods.rs +++ b/library/core/src/char/methods.rs @@ -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 @@ -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 /// @@ -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}; @@ -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 = '💯'; @@ -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 @@ -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; @@ -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`: @@ -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 @@ -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; @@ -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 /// @@ -360,7 +360,7 @@ impl char { /// println!(); /// ``` /// - /// Using `println!` directly: + /// Using [`println!`](macro.println.html) directly: /// /// ``` /// println!("{}", '❤'.escape_unicode()); @@ -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}"); @@ -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 /// @@ -436,7 +436,7 @@ impl char { /// println!(); /// ``` /// - /// Using `println!` directly: + /// Using [`println!`](macro.println.html) directly: /// /// ``` /// println!("{}", '\n'.escape_debug()); @@ -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"); @@ -490,7 +490,7 @@ impl char { /// println!(); /// ``` /// - /// Using `println!` directly: + /// Using [`println!`](macro.println.html) directly: /// /// ``` /// println!("{}", '"'.escape_default()); @@ -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(), "\\\""); @@ -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 @@ -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 @@ -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]; @@ -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`]. @@ -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`]. @@ -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`]. @@ -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`]. /// @@ -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 @@ -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 @@ -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] @@ -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 @@ -925,7 +927,7 @@ impl char { /// println!(); /// ``` /// - /// Using `println!` directly: + /// Using [`println!`](macro.println.html) directly: /// /// ``` /// println!("{}", 'İ'.to_lowercase()); @@ -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"); @@ -990,7 +992,7 @@ impl char { /// println!(); /// ``` /// - /// Using `println!` directly: + /// Using [`println!`](macro.println.html) directly: /// /// ``` /// println!("{}", 'ß'.to_uppercase()); @@ -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"); @@ -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 /// @@ -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] |
