pub struct Char8(/* private fields */);Expand description
An 8-bit unicode scalar value, limited to basic latin and latin-1 subsets.
This is the only scalar type without memory layout optimization
because each possible value is a valid unicode scalar. Therefore
Option<Char8> is the same size as Char16 or Option<Char16> (2 bytes).
Implementations§
Source§impl Char8
impl Char8
Source§impl Char8
impl Char8
Sourcepub const fn from_char7(c: Char7) -> Char8
pub const fn from_char7(c: Char7) -> Char8
Converts a Char7 to Char8.
Sourcepub const fn try_from_char16(c: Char16) -> Result<Char8>
pub const fn try_from_char16(c: Char16) -> Result<Char8>
Tries to convert a Char16 to Char8.
Sourcepub const fn try_from_char24(c: Char24) -> Result<Char8>
pub const fn try_from_char24(c: Char24) -> Result<Char8>
Tries to convert a Char24 to Char8.
Sourcepub const fn try_from_char32(c: Char32) -> Result<Char8>
pub const fn try_from_char32(c: Char32) -> Result<Char8>
Tries to convert a Char32 to Char8.
Sourcepub const fn try_from_char(c: char) -> Result<Char8>
pub const fn try_from_char(c: char) -> Result<Char8>
Tries to convert a char to Char8.
Sourcepub const fn try_to_char7(self) -> Result<Char7>
pub const fn try_to_char7(self) -> Result<Char7>
Tries to convert this Char8 to Char7.
Sourcepub const fn to_utf8_bytes(self) -> [u8; 2]
pub const fn to_utf8_bytes(self) -> [u8; 2]
Converts this Char8 to an UTF-8 encoded sequence of bytes.
Note that this function always returns a 2-byte array, but the actual UTF-8 sequence may be shorter. The unused bytes are set to 0.
Sourcepub const fn is_noncharacter(self) -> bool
pub const fn is_noncharacter(self) -> bool
Returns true if this unicode scalar is a noncharacter.
Sourcepub const fn is_character(self) -> bool
pub const fn is_character(self) -> bool
Returns true if this unicode scalar is an abstract character.
Sourcepub const fn to_ascii_uppercase(self) -> Char8
pub const fn to_ascii_uppercase(self) -> Char8
Makes a copy of the value in its ASCII upper case equivalent.
ASCII letters ‘a’ to ‘z’ are mapped to ‘A’ to ‘Z’, but non-ASCII letters are unchanged.
Sourcepub const fn to_ascii_lowercase(self) -> Char8
pub const fn to_ascii_lowercase(self) -> Char8
Makes a copy of the value in its ASCII lower case equivalent.
ASCII letters ‘A’ to ‘Z’ are mapped to ‘a’ to ‘z’, but non-ASCII letters are unchanged.
Trait Implementations§
Source§impl Chars for Char8
impl Chars for Char8
Source§fn encode_utf8(self, dst: &mut [u8]) -> &mut str
fn encode_utf8(self, dst: &mut [u8]) -> &mut str
Source§fn to_utf8_bytes(self) -> [u8; 4]
fn to_utf8_bytes(self) -> [u8; 4]
scalar to an UTF-8 encoded sequence of bytes. Read moreSource§fn encode_utf16(self, dst: &mut [u16]) -> &mut [u16]
fn encode_utf16(self, dst: &mut [u16]) -> &mut [u16]
Source§fn to_digit(self, radix: u32) -> Option<u32>
fn to_digit(self, radix: u32) -> Option<u32>
Source§fn to_ascii_uppercase(self) -> Self
fn to_ascii_uppercase(self) -> Self
Source§fn to_ascii_lowercase(self) -> Self
fn to_ascii_lowercase(self) -> Self
Source§fn is_noncharacter(self) -> bool
fn is_noncharacter(self) -> bool
true if this unicode scalar is a noncharacter.Source§fn is_digit(self, radix: u32) -> bool
fn is_digit(self, radix: u32) -> bool
Source§fn is_control(self) -> bool
fn is_control(self) -> bool
true if this unicode scalar has the general category for
control codes.Source§fn is_alphabetic(self) -> bool
fn is_alphabetic(self) -> bool
true if this unicode scalar has the Alphabetic property.Source§fn is_numeric(self) -> bool
fn is_numeric(self) -> bool
true if this unicode scalar has one of the general categories
for numbers. Read moreSource§fn is_alphanumeric(self) -> bool
fn is_alphanumeric(self) -> bool
Source§fn is_lowercase(self) -> bool
fn is_lowercase(self) -> bool
true if this unicode scalar has the Lowercase property.Source§fn is_uppercase(self) -> bool
fn is_uppercase(self) -> bool
true if this unicode scalar has the Lowercase property.Source§fn is_whitespace(self) -> bool
fn is_whitespace(self) -> bool
true if this unicode scalar has the White_Space property.Source§fn is_character(self) -> boolwhere
Self: Sized,
fn is_character(self) -> boolwhere
Self: Sized,
true if this unicode scalar is an abstract character.