Enum ascii::AsciiChar [] [src]

#[repr(u8)]
pub enum AsciiChar { Null, SOH, SOX, ETX, EOT, ENQ, ACK, Bell, BackSpace, Tab, LineFeed, VT, FF, CarriageReturn, SI, SO, DLE, DC1, DC2, DC3, DC4, NAK, SYN, ETB, CAN, EM, SUB, ESC, FS, GS, RS, US, Space, Exclamation, Quotation, Hash, Dollar, Percent, Ampersand, Apostrophe, ParenOpen, ParenClose, Asterisk, Plus, Comma, Minus, Dot, Slash, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, Colon, Semicolon, LessThan, Equal, GreaterThan, Question, At, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, BracketOpen, BackSlash, BracketClose, Caret, UnderScore, Grave, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, CurlyBraceOpen, VerticalBar, CurlyBraceClose, Tilde, DEL, }

An ASCII character. It wraps a u8, with the highest bit always zero.

Variants

'\0'

Start Of Heading

Start Of teXt

End of TeXt

End Of Transmission

Enquiry

Acknowledgement

bell / alarm / audible

'\a' is not recognized by Rust.

Backspace

'\b' is not recognized by Rust.

'\t'

'\n'

Vertical tab

'\v' is not recognized by Rust.

Form Feed

'\f' is not recognized by Rust.

'\r'

Shift In

Shift Out

Data Link Escape

Device control 1, often XON

Device control 2

Device control 3, Often XOFF

Device control 4

Negative AcKnowledgement

Synchronous idle

End of Transmission Block

Cancel

End of Medium

Substitute

Escape

'\e' is not recognized by Rust.

File Separator

Group Separator

Record Separator

Unit Separator

' '

'!'

'"'

'#'

'$'

'%'

'&'

'\''

'('

')'

'*'

'+'

','

'-'

'.'

'/'

'0'

'1'

'2'

'3'

'4'

'5'

'6'

'7'

'8'

'9'

':'

';'

'<'

'='

'>'

'?'

'@'

'A'

'B'

'C'

'D'

'E'

'F'

'G'

'H'

'I'

'J'

'K'

'L'

'M'

'N'

'O'

'P'

'Q'

'R'

'S'

'T'

'U'

'V'

'W'

'X'

'Y'

'Z'

'['

'\'

']'

'_'

'_'

''`

'a'

'b'

'c'

'd'

'e'

'f'

'g'

'h'

'i'

'j'

'k'

'l'

'm'

'n'

'o'

'p'

'q'

'r'

's'

't'

'u'

'v'

'w'

'x'

'y'

'z'

'{'

'|'

'}'

'~'

Delete

Methods

impl AsciiChar
[src]

Constructs an ASCII character from a u8, char or other character type.

Failure

Returns Err(()) if the character can't be ASCII encoded.

Example

let a = AsciiChar::from('g').unwrap();
assert_eq!(a.as_char(), 'g');

Constructs an ASCII character from a char or u8 without any checks.

Converts an ASCII character into a u8.

Converts an ASCII character into a char.

Check if the character is a letter (a-z, A-Z)

Check if the character is a number (0-9)

Check if the character is a letter or number

Check if the character is a space or horizontal tab

Check if the character is a ' ', '\t', '\n' or '\r'

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);

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);

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);

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);

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);

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);

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);

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');

Maps letters a...z to A...Z and returns everything else unchanged.

A replacement for AsciiExt::to_ascii_uppercase().

Maps letters A...Z to a...z and returns everything else unchanged.

A replacement for AsciiExt::to_ascii_lowercase().

Compares two characters case-insensitively.

A replacement for AsciiExt::eq_ignore_ascii_case().

Trait Implementations

impl Clone for AsciiChar
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl PartialEq for AsciiChar
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl PartialOrd for AsciiChar
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Ord for AsciiChar
[src]

This method returns an Ordering between self and other. Read more

impl Eq for AsciiChar
[src]

impl Hash for AsciiChar
[src]

Feeds this value into the state given, updating the hasher as necessary.

Feeds a slice of this type into the state provided.

impl Copy for AsciiChar
[src]

impl Display for AsciiChar
[src]

Formats the value using the given formatter. Read more

impl Debug for AsciiChar
[src]

Formats the value using the given formatter.

impl PartialEq<u8> for AsciiChar
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl PartialOrd<u8> for AsciiChar
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl PartialEq<char> for AsciiChar
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl PartialOrd<char> for AsciiChar
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl ToAsciiChar for AsciiChar
[src]

Convert to AsciiChar.

Convert to AsciiChar without checking that it is an ASCII character.