Function malachite_base::chars::crement::contiguous_range_to_char
source · pub const fn contiguous_range_to_char(u: u32) -> Option<char>
Expand description
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));