konst::chr

Function from_u32_unchecked

Source
pub const unsafe fn from_u32_unchecked(n: u32) -> char
Expand description

Unsafely coerces u32 to char, const equivalent of char::from_u32_unchecked

§Const stabilization

The equivalent std function was const-stabilized in Rust 1.82.0.

§Safety

The input u32 must be within either of these ranges:

  • 0..=0xD7FF
  • 0xE000..=0x10FFFF

§Example

use konst::chr;

const AT: char = unsafe { chr::from_u32_unchecked(64) };

assert_eq!(AT, '@');