pub trait UnicodeScalar {
const MIN: Self;
const MAX: Self;
Show 21 methods
// Required methods
fn byte_len(self) -> usize ⓘ;
fn len_utf8(self) -> usize ⓘ;
fn len_utf16(self) -> usize ⓘ;
fn encode_utf8(self, dst: &mut [u8]) -> &mut str ⓘ;
fn to_utf8_bytes(self) -> [u8; 4];
fn encode_utf16(self, dst: &mut [u16]) -> &mut [u16] ⓘ;
fn to_digit(self, radix: u32) -> Option<u32> ⓘ;
fn to_ascii_uppercase(self) -> Self
where Self: Sized;
fn to_ascii_lowercase(self) -> Self
where Self: Sized;
fn is_noncharacter(self) -> bool;
fn is_digit(self, radix: u32) -> bool;
fn is_control(self) -> bool;
fn is_nul(self) -> bool;
fn is_alphabetic(self) -> bool;
fn is_numeric(self) -> bool;
fn is_alphanumeric(self) -> bool;
fn is_lowercase(self) -> bool;
fn is_uppercase(self) -> bool;
fn is_whitespace(self) -> bool;
fn is_ascii(self) -> bool;
// Provided method
fn is_character(self) -> bool
where Self: Sized { ... }
}
Expand description
Required Associated Constants§
Required Methods§
Sourcefn encode_utf8(self, dst: &mut [u8]) -> &mut str ⓘ
fn encode_utf8(self, dst: &mut [u8]) -> &mut str ⓘ
Encodes this scalar as UTF-8 into the provided byte buffer, and then returns the subslice of the buffer that contains the encoded scalar.
§Panics
Panics if the buffer is not large enough. A buffer of length four is large enough to encode any char.
Sourcefn to_utf8_bytes(self) -> [u8; 4]
fn to_utf8_bytes(self) -> [u8; 4]
Converts this scalar
to an UTF-8 encoded sequence of bytes.
Note that this function always returns a 4-byte array, but the actual UTF-8 sequence may be shorter. The unused bytes are set to 0.
Sourcefn encode_utf16(self, dst: &mut [u16]) -> &mut [u16] ⓘ
fn encode_utf16(self, dst: &mut [u16]) -> &mut [u16] ⓘ
Encodes this scalar as UTF-16 into the provided byte buffer, and then returns the subslice of the buffer that contains the encoded scalar.
§Panics
Panics if the buffer is not large enough. A buffer of length 2 is large enough to encode any char.
Sourcefn to_ascii_uppercase(self) -> Selfwhere
Self: Sized,
fn to_ascii_uppercase(self) -> Selfwhere
Self: Sized,
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.
Sourcefn to_ascii_lowercase(self) -> Selfwhere
Self: Sized,
fn to_ascii_lowercase(self) -> Selfwhere
Self: Sized,
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.
Sourcefn is_noncharacter(self) -> bool
fn is_noncharacter(self) -> bool
Returns true
if this unicode scalar is a noncharacter.
Sourcefn is_digit(self, radix: u32) -> bool
fn is_digit(self, radix: u32) -> bool
Checks if the unicode scalar is a digit in the given radix.
See also to_digit
.
Sourcefn is_control(self) -> bool
fn is_control(self) -> bool
Returns true
if this unicode scalar has the general category for
control codes.
Sourcefn is_alphabetic(self) -> bool
fn is_alphabetic(self) -> bool
Returns true
if this unicode scalar has the Alphabetic
property.
Sourcefn is_numeric(self) -> bool
fn is_numeric(self) -> bool
Returns true
if this unicode scalar has one of the general categories
for numbers.
If you want to parse ASCII decimal digits (0-9) or ASCII base-N,
use is_ascii_digit
or
is_digit
instead.
Sourcefn is_alphanumeric(self) -> bool
fn is_alphanumeric(self) -> bool
Returns true
if this unicode scalar satisfies either
is_alphabetic()
or
is_numeric()
.
Sourcefn is_lowercase(self) -> bool
fn is_lowercase(self) -> bool
Returns true
if this unicode scalar has the Lowercase
property.
Sourcefn is_uppercase(self) -> bool
fn is_uppercase(self) -> bool
Returns true
if this unicode scalar has the Lowercase
property.
Sourcefn is_whitespace(self) -> bool
fn is_whitespace(self) -> bool
Returns true
if this unicode scalar has the White_Space
property.
Provided Methods§
Sourcefn is_character(self) -> boolwhere
Self: Sized,
fn is_character(self) -> boolwhere
Self: Sized,
Returns true
if this unicode scalar is an abstract character.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.