File tree Expand file tree Collapse file tree 2 files changed +22
-12
lines changed Expand file tree Collapse file tree 2 files changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -9,14 +9,19 @@ use super::*;
99
1010#[ lang = "char" ]  
1111impl  char  { 
12-     /// The highest valid code point a `char` can have. 
12+     /// The highest valid code point a `char` can have, `'\u{10FFFF}'` . 
1313/// 
14- /// A `char` is a [Unicode Scalar Value], which means that it is a [Code 
15- /// Point], but only ones within a certain range. `MAX` is the highest valid 
16- /// code point that's a valid [Unicode Scalar Value]. 
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); 
1720/// 
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+ /// ``` 
2025#[ stable( feature = "assoc_char_consts" ,  since = "1.52.0" ) ]  
2126    pub  const  MAX :  char  = '\u{10ffff}' ; 
2227
Original file line number Diff line number Diff line change @@ -89,14 +89,19 @@ const MAX_THREE_B: u32 = 0x10000;
8989    Cn  Unassigned              a reserved unassigned code point or a noncharacter 
9090*/ 
9191
92- /// The highest valid code point a `char` can have. 
92+ /// The highest valid code point a `char` can have, `'\u{10FFFF}'` . 
9393/// 
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 
9795/// 
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+ /// ``` 
100105#[ stable( feature = "rust1" ,  since = "1.0.0" ) ]  
101106pub  const  MAX :  char  = char:: MAX ; 
102107
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments