@@ -11,9 +11,27 @@ use super::*;
11
11
impl char {
12
12
/// The lowest valid code point a `char` can have, `'\0'`.
13
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();
23
+ /// assert!(dist < size);
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
+ ///
14
31
/// # Examples
15
32
///
16
33
/// ```
34
+ /// #![feature(char_min)]
17
35
/// # fn something_which_returns_char() -> char { 'a' }
18
36
/// let c: char = something_which_returns_char();
19
37
/// assert!(char::MIN <= c);
@@ -26,6 +44,23 @@ impl char {
26
44
27
45
/// The highest valid code point a `char` can have, `'\u{10FFFF}'`.
28
46
///
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();
56
+ /// assert!(dist < size);
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
+ ///
29
64
/// # Examples
30
65
///
31
66
/// ```
0 commit comments