@@ -9,16 +9,66 @@ use crate::unicode::{self, conversions};
99use super :: * ;
1010
1111impl char {
12+ /// The lowest valid code point a `char` can have, `'\0'`.
13+ ///
14+ /// Unlike integer types, `char` actually has a gap in the middle,
15+ /// meaning that the range of possible `char`s is smaller than you
16+ /// might expect. Ranges of `char` will automatically hop this gap
17+ /// for you:
18+ ///
19+ /// ```
20+ /// #![feature(char_min)]
21+ /// let dist = u32::from(char::MAX) - u32::from(char::MIN);
22+ /// let size = (char::MIN..=char::MAX).count() as u32;
23+ /// assert!(size < dist);
24+ /// ```
25+ ///
26+ /// Despite this gap, the `MIN` and [`MAX`] values can be used as bounds for
27+ /// all `char` values.
28+ ///
29+ /// [`MAX`]: char::MAX
30+ ///
31+ /// # Examples
32+ ///
33+ /// ```
34+ /// #![feature(char_min)]
35+ /// # fn something_which_returns_char() -> char { 'a' }
36+ /// let c: char = something_which_returns_char();
37+ /// assert!(char::MIN <= c);
38+ ///
39+ /// let value_at_min = u32::from(char::MIN);
40+ /// assert_eq!(char::from_u32(value_at_min), Some('\0'));
41+ /// ```
42+ #[ unstable( feature = "char_min" , issue = "114298" ) ]
43+ pub const MIN : char = '\0' ;
44+
1245 /// The highest valid code point a `char` can have, `'\u{10FFFF}'`.
1346 ///
47+ /// Unlike integer types, `char` actually has a gap in the middle,
48+ /// meaning that the range of possible `char`s is smaller than you
49+ /// might expect. Ranges of `char` will automatically hop this gap
50+ /// for you:
51+ ///
52+ /// ```
53+ /// #![feature(char_min)]
54+ /// let dist = u32::from(char::MAX) - u32::from(char::MIN);
55+ /// let size = (char::MIN..=char::MAX).count() as u32;
56+ /// assert!(size < dist);
57+ /// ```
58+ ///
59+ /// Despite this gap, the [`MIN`] and `MAX` values can be used as bounds for
60+ /// all `char` values.
61+ ///
62+ /// [`MIN`]: char::MIN
63+ ///
1464 /// # Examples
1565 ///
1666 /// ```
1767 /// # fn something_which_returns_char() -> char { 'a' }
1868 /// let c: char = something_which_returns_char();
1969 /// assert!(c <= char::MAX);
2070 ///
21- /// let value_at_max = char::MAX as u32 ;
71+ /// let value_at_max = u32::from( char::MAX) ;
2272 /// assert_eq!(char::from_u32(value_at_max), Some('\u{10FFFF}'));
2373 /// assert_eq!(char::from_u32(value_at_max + 1), None);
2474 /// ```
0 commit comments