konst::chr

Function encode_utf8

Source
pub const fn encode_utf8(char: char) -> Utf8Encoded
Expand description

Encodes c into utf8, const analog of char::encode_utf8.

§Const stabilization

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

§Example

use konst::chr;

const ENC: &chr::Utf8Encoded = &chr::encode_utf8('🤔');
const ENC_STR: &str = ENC.as_str();

assert_eq!(ENC_STR, "🤔");