File tree 2 files changed +22
-12
lines changed
2 files changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -9,14 +9,19 @@ use super::*;
9
9
10
10
#[ lang = "char" ]
11
11
impl char {
12
- /// The highest valid code point a `char` can have, 0x10FFFF .
12
+ /// The highest valid code point a `char` can have, `'\u{10FFFF}'` .
13
13
///
14
- /// A [Code Point] is any value between zero and `char::MAX`, inclusive. A
15
- /// `char` is a [Unicode Scalar Value], which is a Code Point that is not
16
- /// in the range `0xD800..=0xDFFF`.
14
+ /// # Examples
15
+ ///
16
+ /// ```
17
+ /// # fn something_which_returns_char() -> char { 'a' }
18
+ /// let c: char = something_which_returns_char();
19
+ /// assert!(c <= char::MAX);
17
20
///
18
- /// [Unicode Scalar Value]: https://www.unicode.org/glossary/#unicode_scalar_value
19
- /// [Code Point]: https://www.unicode.org/glossary/#code_point
21
+ /// let value_at_max = char::MAX as u32;
22
+ /// assert_eq!(char::from_u32(value_at_max), Some('\u{10FFFF}'));
23
+ /// assert_eq!(char::from_u32(value_at_max + 1), None);
24
+ /// ```
20
25
#[ stable( feature = "assoc_char_consts" , since = "1.52.0" ) ]
21
26
pub const MAX : char = '\u{10ffff}' ;
22
27
Original file line number Diff line number Diff line change @@ -89,14 +89,19 @@ const MAX_THREE_B: u32 = 0x10000;
89
89
Cn Unassigned a reserved unassigned code point or a noncharacter
90
90
*/
91
91
92
- /// The highest valid code point a `char` can have.
92
+ /// The highest valid code point a `char` can have, `'\u{10FFFF}'` .
93
93
///
94
- /// A [`char`] is a [Unicode Scalar Value], which means that it is a [Code
95
- /// Point], but only ones within a certain range. `MAX` is the highest valid
96
- /// code point that's a valid [Unicode Scalar Value].
94
+ /// # Examples
97
95
///
98
- /// [Unicode Scalar Value]: https://www.unicode.org/glossary/#unicode_scalar_value
99
- /// [Code Point]: https://www.unicode.org/glossary/#code_point
96
+ /// ```
97
+ /// # fn something_which_returns_char() -> char { 'a' }
98
+ /// let c: char = something_which_returns_char();
99
+ /// assert!(c <= char::MAX);
100
+ ///
101
+ /// let value_at_max = char::MAX as u32;
102
+ /// assert_eq!(char::from_u32(value_at_max), Some('\u{10FFFF}'));
103
+ /// assert_eq!(char::from_u32(value_at_max + 1), None);
104
+ /// ```
100
105
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
101
106
pub const MAX : char = char:: MAX ;
102
107
You can’t perform that action at this time.
0 commit comments