devela/text/char/impls/
c.rs
1use crate::{Char, UnicodeScalar};
8
9impl UnicodeScalar for char {
10 const MIN: Self = Self::MIN;
11 const MAX: Self = Self::MAX;
12
13 fn byte_len(self) -> usize {
16 Char::byte_len(self as u32)
17 }
18 fn len_utf8(self) -> usize {
19 self.len_utf8()
20 }
21 fn len_utf16(self) -> usize {
22 self.len_utf16()
23 }
24 fn encode_utf8(self, dst: &mut [u8]) -> &mut str {
25 self.encode_utf8(dst)
26 }
27 fn to_utf8_bytes(self) -> [u8; 4] {
28 Char::to_utf8_bytes(self)
29 }
30 fn encode_utf16(self, dst: &mut [u16]) -> &mut [u16] {
31 self.encode_utf16(dst)
32 }
33 fn to_digit(self, radix: u32) -> Option<u32> {
34 self.to_digit(radix)
35 }
36 fn to_ascii_uppercase(self) -> char {
37 char::to_ascii_uppercase(&self)
38 }
39 fn to_ascii_lowercase(self) -> char {
40 char::to_ascii_lowercase(&self)
41 }
42
43 fn is_noncharacter(self) -> bool {
46 Char::is_noncharacter(self as u32)
47 }
48 fn is_digit(self, radix: u32) -> bool {
49 self.is_digit(radix)
50 }
51 fn is_control(self) -> bool {
52 self.is_control()
53 }
54 fn is_nul(self) -> bool {
55 self as u32 == 0
56 }
57 fn is_alphabetic(self) -> bool {
58 self.is_alphabetic()
59 }
60 fn is_numeric(self) -> bool {
61 self.is_numeric()
62 }
63 fn is_alphanumeric(self) -> bool {
64 self.is_alphanumeric()
65 }
66 fn is_lowercase(self) -> bool {
67 self.is_lowercase()
68 }
69 fn is_uppercase(self) -> bool {
70 self.is_uppercase()
71 }
72 fn is_whitespace(self) -> bool {
73 self.is_whitespace()
74 }
75
76 fn is_ascii(self) -> bool {
79 (self as u32) <= 0x7F
80 }
81}