use crate;
use crate Min;
/// Converts a [`char`] to a [`u32`].
///
/// The conversion is done in such a way that if the next largest [`char`] after $x$ is $y$, then
/// $\mathrm{char\\_to\\_contiguous\\_range(x)}+1 = \mathrm{char\\_to\\_contiguous\\_range(y)}$.
/// This can't be accomplished just through casting, because there is a range of [`u32`]s (the
/// [surrogate code points](https://www.unicode.org/glossary/#surrogate_code_point)) that do not
/// correspond to any [`char`].
///
/// The inverse of this function is [`contiguous_range_to_char`].
///
/// # Worst-case complexity
/// Constant time and additional memory.
///
/// # Examples
/// ```
/// use malachite_base::chars::crement::char_to_contiguous_range;
/// use std::char;
///
/// assert_eq!(char_to_contiguous_range('\u{0}'), 0);
/// assert_eq!(char_to_contiguous_range('a'), 97);
/// assert_eq!(char_to_contiguous_range(char::MAX), 1112063);
/// ```
pub const
/// Converts a [`u32`] to a [`char`]; if all [`char`]s were arranged in ascending order, passing
/// $u$ to this function would return the $u$th [`char`].
///
/// This function is the inverse of [`char_to_contiguous_range`]. Every [`u32`] between $0$ and
/// $\mathrm{NUMBER\\_OF\\_CHARS} - 1$, inclusive, is mapped to a distinct [`char`]. Passing a
/// larger [`u32`] yields `None`.
///
/// # Worst-case complexity
/// Constant time and additional memory.
///
/// # Examples
/// ```
/// use malachite_base::chars::crement::contiguous_range_to_char;
/// use std::char;
///
/// assert_eq!(contiguous_range_to_char(0), Some('\u{0}'));
/// assert_eq!(contiguous_range_to_char(97), Some('a'));
/// assert_eq!(contiguous_range_to_char(1112063), Some(char::MAX));
/// ```
/// Increments this [`char`], skipping over the
/// [surrogate code points](https://www.unicode.org/glossary/#surrogate_code_point).
///
/// # Panics
/// Panics if `self` is `char::MAX`.
///
/// # Examples
/// ```
/// use malachite_base::chars::crement::increment_char;
///
/// let mut c = '\u{0}';
/// increment_char(&mut c);
/// assert_eq!(c, '\u{1}');
///
/// let mut c = 'a';
/// increment_char(&mut c);
/// assert_eq!(c, 'b');
/// ```
/// Decrements this [`char`], skipping over the
/// [surrogate code points](https://www.unicode.org/glossary/#surrogate_code_point).
///
/// # Worst-case complexity
/// Constant time and additional memory.
///
/// # Panics
/// Panics if `self` is `'\u{0}'`.
///
/// # Examples
/// ```
/// use malachite_base::chars::crement::decrement_char;
///
/// let mut c = '\u{1}';
/// decrement_char(&mut c);
/// assert_eq!(c, '\u{0}');
///
/// let mut c = 'b';
/// decrement_char(&mut c);
/// assert_eq!(c, 'a');
/// ```