#[repr(u8)]pub enum AsciiChar {
Show 128 variants
Null = 0,
SOH = 1,
SOX = 2,
ETX = 3,
EOT = 4,
ENQ = 5,
ACK = 6,
Bell = 7,
BackSpace = 8,
Tab = 9,
LineFeed = 10,
VT = 11,
FF = 12,
CarriageReturn = 13,
SI = 14,
SO = 15,
DLE = 16,
DC1 = 17,
DC2 = 18,
DC3 = 19,
DC4 = 20,
NAK = 21,
SYN = 22,
ETB = 23,
CAN = 24,
EM = 25,
SUB = 26,
ESC = 27,
FS = 28,
GS = 29,
RS = 30,
US = 31,
Space = 32,
Exclamation = 33,
Quotation = 34,
Hash = 35,
Dollar = 36,
Percent = 37,
Ampersand = 38,
Apostrophe = 39,
ParenOpen = 40,
ParenClose = 41,
Asterisk = 42,
Plus = 43,
Comma = 44,
Minus = 45,
Dot = 46,
Slash = 47,
_0 = 48,
_1 = 49,
_2 = 50,
_3 = 51,
_4 = 52,
_5 = 53,
_6 = 54,
_7 = 55,
_8 = 56,
_9 = 57,
Colon = 58,
Semicolon = 59,
LessThan = 60,
Equal = 61,
GreaterThan = 62,
Question = 63,
At = 64,
A = 65,
B = 66,
C = 67,
D = 68,
E = 69,
F = 70,
G = 71,
H = 72,
I = 73,
J = 74,
K = 75,
L = 76,
M = 77,
N = 78,
O = 79,
P = 80,
Q = 81,
R = 82,
S = 83,
T = 84,
U = 85,
V = 86,
W = 87,
X = 88,
Y = 89,
Z = 90,
BracketOpen = 91,
BackSlash = 92,
BracketClose = 93,
Caret = 94,
UnderScore = 95,
Grave = 96,
a = 97,
b = 98,
c = 99,
d = 100,
e = 101,
f = 102,
g = 103,
h = 104,
i = 105,
j = 106,
k = 107,
l = 108,
m = 109,
n = 110,
o = 111,
p = 112,
q = 113,
r = 114,
s = 115,
t = 116,
u = 117,
v = 118,
w = 119,
x = 120,
y = 121,
z = 122,
CurlyBraceOpen = 123,
VerticalBar = 124,
CurlyBraceClose = 125,
Tilde = 126,
DEL = 127,
}
Expand description
An ASCII character. It wraps a u8
, with the highest bit always zero.
Variants§
Null = 0
'\0'
SOH = 1
SOX = 2
ETX = 3
EOT = 4
ENQ = 5
ACK = 6
Bell = 7
'\a'
is not recognized by Rust.
BackSpace = 8
'\b'
is not recognized by Rust.
Tab = 9
'\t'
LineFeed = 10
'\n'
VT = 11
'\v'
is not recognized by Rust.
FF = 12
'\f'
is not recognized by Rust.
CarriageReturn = 13
'\r'
SI = 14
SO = 15
DLE = 16
DC1 = 17
DC2 = 18
Device control 2
DC3 = 19
Device control 3, Often XOFF
DC4 = 20
Device control 4
NAK = 21
SYN = 22
ETB = 23
CAN = 24
EM = 25
SUB = 26
ESC = 27
'\e'
is not recognized by Rust.
FS = 28
GS = 29
RS = 30
US = 31
Space = 32
' '
Exclamation = 33
'!'
Quotation = 34
'"'
Hash = 35
'#'
Dollar = 36
'$'
Percent = 37
'%'
Ampersand = 38
'&'
Apostrophe = 39
'\''
ParenOpen = 40
'('
ParenClose = 41
')'
Asterisk = 42
'*'
Plus = 43
'+'
Comma = 44
','
Minus = 45
'-'
Dot = 46
'.'
Slash = 47
'/'
_0 = 48
'0'
_1 = 49
'1'
_2 = 50
'2'
_3 = 51
'3'
_4 = 52
'4'
_5 = 53
'5'
_6 = 54
'6'
_7 = 55
'7'
_8 = 56
'8'
_9 = 57
'9'
Colon = 58
':'
Semicolon = 59
';'
LessThan = 60
'<'
Equal = 61
'='
GreaterThan = 62
'>'
Question = 63
'?'
At = 64
'@'
A = 65
'A'
B = 66
'B'
C = 67
'C'
D = 68
'D'
E = 69
'E'
F = 70
'F'
G = 71
'G'
H = 72
'H'
I = 73
'I'
J = 74
'J'
K = 75
'K'
L = 76
'L'
M = 77
'M'
N = 78
'N'
O = 79
'O'
P = 80
'P'
Q = 81
'Q'
R = 82
'R'
S = 83
'S'
T = 84
'T'
U = 85
'U'
V = 86
'V'
W = 87
'W'
X = 88
'X'
Y = 89
'Y'
Z = 90
'Z'
BracketOpen = 91
'['
BackSlash = 92
'\'
BracketClose = 93
']'
Caret = 94
'_'
UnderScore = 95
'_'
Grave = 96
'
’`
a = 97
'a'
b = 98
'b'
c = 99
'c'
d = 100
'd'
e = 101
'e'
f = 102
'f'
g = 103
'g'
h = 104
'h'
i = 105
'i'
j = 106
'j'
k = 107
'k'
l = 108
'l'
m = 109
'm'
n = 110
'n'
o = 111
'o'
p = 112
'p'
q = 113
'q'
r = 114
'r'
s = 115
's'
t = 116
't'
u = 117
'u'
v = 118
'v'
w = 119
'w'
x = 120
'x'
y = 121
'y'
z = 122
'z'
CurlyBraceOpen = 123
'{'
VerticalBar = 124
'|'
CurlyBraceClose = 125
'}'
Tilde = 126
'~'
DEL = 127
Implementations§
Source§impl AsciiChar
impl AsciiChar
Sourcepub fn from<C: ToAsciiChar>(ch: C) -> Result<Self, ToAsciiCharError>
pub fn from<C: ToAsciiChar>(ch: C) -> Result<Self, ToAsciiCharError>
Sourcepub unsafe fn from_unchecked<C: ToAsciiChar>(ch: C) -> Self
pub unsafe fn from_unchecked<C: ToAsciiChar>(ch: C) -> Self
Constructs an ASCII character from a char
or u8
without any checks.
Sourcepub fn is_alphabetic(self) -> bool
pub fn is_alphabetic(self) -> bool
Check if the character is a letter (a-z, A-Z)
Sourcepub fn is_alphanumeric(self) -> bool
pub fn is_alphanumeric(self) -> bool
Check if the character is a letter or number
Sourcepub fn is_whitespace(self) -> bool
pub fn is_whitespace(self) -> bool
Check if the character is a ’ ’, ‘\t’, ‘\n’ or ‘\r’
Sourcepub fn is_control(self) -> bool
pub fn is_control(self) -> bool
Check if the character is a control character
§Examples
use ascii::ToAsciiChar;
assert_eq!('\0'.to_ascii_char().unwrap().is_control(), true);
assert_eq!('n'.to_ascii_char().unwrap().is_control(), false);
assert_eq!(' '.to_ascii_char().unwrap().is_control(), false);
assert_eq!('\n'.to_ascii_char().unwrap().is_control(), true);
Sourcepub fn is_graph(self) -> bool
pub fn is_graph(self) -> bool
Checks if the character is printable (except space)
§Examples
use ascii::ToAsciiChar;
assert_eq!('n'.to_ascii_char().unwrap().is_graph(), true);
assert_eq!(' '.to_ascii_char().unwrap().is_graph(), false);
assert_eq!('\n'.to_ascii_char().unwrap().is_graph(), false);
Sourcepub fn is_print(self) -> bool
pub fn is_print(self) -> bool
Checks if the character is printable (including space)
§Examples
use ascii::ToAsciiChar;
assert_eq!('n'.to_ascii_char().unwrap().is_print(), true);
assert_eq!(' '.to_ascii_char().unwrap().is_print(), true);
assert_eq!('\n'.to_ascii_char().unwrap().is_print(), false);
Sourcepub fn is_lowercase(self) -> bool
pub fn is_lowercase(self) -> bool
Checks if the character is alphabetic and lowercase
§Examples
use ascii::ToAsciiChar;
assert_eq!('a'.to_ascii_char().unwrap().is_lowercase(), true);
assert_eq!('A'.to_ascii_char().unwrap().is_lowercase(), false);
assert_eq!('@'.to_ascii_char().unwrap().is_lowercase(), false);
Sourcepub fn is_uppercase(self) -> bool
pub fn is_uppercase(self) -> bool
Checks if the character is alphabetic and uppercase
§Examples
use ascii::ToAsciiChar;
assert_eq!('A'.to_ascii_char().unwrap().is_uppercase(), true);
assert_eq!('a'.to_ascii_char().unwrap().is_uppercase(), false);
assert_eq!('@'.to_ascii_char().unwrap().is_uppercase(), false);
Sourcepub fn is_punctuation(self) -> bool
pub fn is_punctuation(self) -> bool
Checks if the character is punctuation
§Examples
use ascii::ToAsciiChar;
assert_eq!('n'.to_ascii_char().unwrap().is_punctuation(), false);
assert_eq!(' '.to_ascii_char().unwrap().is_punctuation(), false);
assert_eq!('_'.to_ascii_char().unwrap().is_punctuation(), true);
assert_eq!('~'.to_ascii_char().unwrap().is_punctuation(), true);
Sourcepub fn is_hex(self) -> bool
pub fn is_hex(self) -> bool
Checks if the character is a valid hex digit
§Examples
use ascii::ToAsciiChar;
assert_eq!('5'.to_ascii_char().unwrap().is_hex(), true);
assert_eq!('a'.to_ascii_char().unwrap().is_hex(), true);
assert_eq!('F'.to_ascii_char().unwrap().is_hex(), true);
assert_eq!('G'.to_ascii_char().unwrap().is_hex(), false);
assert_eq!(' '.to_ascii_char().unwrap().is_hex(), false);
Sourcepub fn as_printable_char(self) -> char
pub fn as_printable_char(self) -> char
Unicode has printable versions of the ASCII control codes, like ‘␛’.
This function is identical with .as_char()
for all values .is_printable()
returns true for,
but replaces the control codes with those unicodes printable versions.
§Examples
assert_eq!('\0'.to_ascii_char().unwrap().as_printable_char(), '␀');
assert_eq!('\n'.to_ascii_char().unwrap().as_printable_char(), '␊');
assert_eq!(' '.to_ascii_char().unwrap().as_printable_char(), ' ');
assert_eq!('p'.to_ascii_char().unwrap().as_printable_char(), 'p');
Sourcepub fn make_ascii_uppercase(&mut self)
pub fn make_ascii_uppercase(&mut self)
Replaces letters a
to z
with A
to Z
Sourcepub fn make_ascii_lowercase(&mut self)
pub fn make_ascii_lowercase(&mut self)
Replaces letters A
to Z
with a
to z
Sourcepub fn to_ascii_uppercase(&self) -> Self
pub fn to_ascii_uppercase(&self) -> Self
Maps letters a
…z
to A
…Z
and returns everything else unchanged.
Sourcepub fn to_ascii_lowercase(&self) -> Self
pub fn to_ascii_lowercase(&self) -> Self
Maps letters A
…Z
to a
…z
and returns everything else unchanged.
Sourcepub fn eq_ignore_ascii_case(&self, other: &Self) -> bool
pub fn eq_ignore_ascii_case(&self, other: &Self) -> bool
Compares two characters case-insensitively.
Trait Implementations§
Source§impl AsciiExt for AsciiChar
impl AsciiExt for AsciiChar
Source§type Owned = AsciiChar
type Owned = AsciiChar
Source§fn is_ascii(&self) -> bool
fn is_ascii(&self) -> bool
Source§fn to_ascii_uppercase(&self) -> AsciiChar
fn to_ascii_uppercase(&self) -> AsciiChar
Source§fn to_ascii_lowercase(&self) -> AsciiChar
fn to_ascii_lowercase(&self) -> AsciiChar
Source§fn eq_ignore_ascii_case(&self, other: &Self) -> bool
fn eq_ignore_ascii_case(&self, other: &Self) -> bool
Source§fn make_ascii_uppercase(&mut self)
fn make_ascii_uppercase(&mut self)
Source§fn make_ascii_lowercase(&mut self)
fn make_ascii_lowercase(&mut self)
Source§impl<'a> Extend<&'a AsciiChar> for AsciiString
impl<'a> Extend<&'a AsciiChar> for AsciiString
Source§fn extend<I: IntoIterator<Item = &'a AsciiChar>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = &'a AsciiChar>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl Extend<AsciiChar> for AsciiString
impl Extend<AsciiChar> for AsciiString
Source§fn extend<I: IntoIterator<Item = AsciiChar>>(&mut self, iterable: I)
fn extend<I: IntoIterator<Item = AsciiChar>>(&mut self, iterable: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl FromIterator<AsciiChar> for AsciiString
impl FromIterator<AsciiChar> for AsciiString
Source§fn from_iter<I: IntoIterator<Item = AsciiChar>>(iter: I) -> AsciiString
fn from_iter<I: IntoIterator<Item = AsciiChar>>(iter: I) -> AsciiString
Source§impl Ord for AsciiChar
impl Ord for AsciiChar
Source§impl PartialOrd<AsciiChar> for char
impl PartialOrd<AsciiChar> for char
Source§impl PartialOrd<AsciiChar> for u8
impl PartialOrd<AsciiChar> for u8
Source§impl PartialOrd<char> for AsciiChar
impl PartialOrd<char> for AsciiChar
Source§impl PartialOrd<u8> for AsciiChar
impl PartialOrd<u8> for AsciiChar
Source§impl PartialOrd for AsciiChar
impl PartialOrd for AsciiChar
Source§impl ToAsciiChar for AsciiChar
impl ToAsciiChar for AsciiChar
Source§fn to_ascii_char(self) -> Result<AsciiChar, ToAsciiCharError>
fn to_ascii_char(self) -> Result<AsciiChar, ToAsciiCharError>
AsciiChar
.Source§unsafe fn to_ascii_char_unchecked(self) -> AsciiChar
unsafe fn to_ascii_char_unchecked(self) -> AsciiChar
AsciiChar
without checking that it is an ASCII character.