Enum ascii::AsciiChar [−][src]
An ASCII character. It wraps a u8
, with the highest bit always zero.
Variants
'\0'
'\a'
is not recognized by Rust.
'\b'
is not recognized by Rust.
'\t'
'\n'
'\v'
is not recognized by Rust.
'\f'
is not recognized by Rust.
'\r'
Device control 2
Device control 3, Often XOFF
Device control 4
'\e'
is not recognized by Rust.
' '
'!'
'"'
'#'
'$'
'%'
'&'
'\''
'('
')'
'*'
'+'
','
'-'
'.'
'/'
'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'
'{'
'|'
'}'
'~'
Implementations
impl AsciiChar
[src]
pub fn from<C: ToAsciiChar>(ch: C) -> Result<Self, ToAsciiCharError>
[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');
pub unsafe fn from_unchecked<C: ToAsciiChar>(ch: C) -> Self
[src]
Constructs an ASCII character from a char
or u8
without any checks.
pub fn as_byte(self) -> u8
[src]
Converts an ASCII character into a u8
.
pub fn as_char(self) -> char
[src]
Converts an ASCII character into a char
.
pub fn is_alphabetic(self) -> bool
[src]
Check if the character is a letter (a-z, A-Z)
pub fn is_digit(self) -> bool
[src]
Check if the character is a number (0-9)
pub fn is_alphanumeric(self) -> bool
[src]
Check if the character is a letter or number
pub fn is_blank(self) -> bool
[src]
Check if the character is a space or horizontal tab
pub fn is_whitespace(self) -> bool
[src]
Check if the character is a ’ ’, ‘\t’, ‘\n’ or ‘\r’
pub fn is_control(self) -> bool
[src]
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);
pub fn is_graph(self) -> bool
[src]
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);
pub fn is_print(self) -> bool
[src]
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);
pub fn is_lowercase(self) -> bool
[src]
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);
pub fn is_uppercase(self) -> bool
[src]
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);
pub fn is_punctuation(self) -> bool
[src]
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);
pub fn is_hex(self) -> bool
[src]
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);
pub fn as_printable_char(self) -> char
[src]
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');
pub fn make_ascii_uppercase(&mut self)
[src]
Replaces letters a
to z
with A
to Z
pub fn make_ascii_lowercase(&mut self)
[src]
Replaces letters A
to Z
with a
to z
pub fn to_ascii_uppercase(&self) -> Self
[src]
Maps letters a
…z
to A
…Z
and returns everything else unchanged.
pub fn to_ascii_lowercase(&self) -> Self
[src]
Maps letters A
…Z
to a
…z
and returns everything else unchanged.
pub fn eq_ignore_ascii_case(&self, other: &Self) -> bool
[src]
Compares two characters case-insensitively.
Trait Implementations
impl AsciiExt for AsciiChar
[src]
type Owned = AsciiChar
use inherent methods instead
Container type for copied ASCII characters.
fn is_ascii(&self) -> bool
[src]
fn to_ascii_uppercase(&self) -> AsciiChar
[src]
fn to_ascii_lowercase(&self) -> AsciiChar
[src]
fn eq_ignore_ascii_case(&self, other: &Self) -> bool
[src]
fn make_ascii_uppercase(&mut self)
[src]
fn make_ascii_lowercase(&mut self)
[src]
impl Clone for AsciiChar
[src]
impl Copy for AsciiChar
[src]
impl Debug for AsciiChar
[src]
impl Default for AsciiChar
[src]
impl Display for AsciiChar
[src]
impl Eq for AsciiChar
[src]
impl<'a> Extend<&'a AsciiChar> for AsciiString
[src]
fn extend<I: IntoIterator<Item = &'a AsciiChar>>(&mut self, iter: I)
[src]
pub fn extend_one(&mut self, item: A)
[src]
pub fn extend_reserve(&mut self, additional: usize)
[src]
impl Extend<AsciiChar> for AsciiString
[src]
fn extend<I: IntoIterator<Item = AsciiChar>>(&mut self, iterable: I)
[src]
pub fn extend_one(&mut self, item: A)
[src]
pub fn extend_reserve(&mut self, additional: usize)
[src]
impl From<AsciiChar> for u8
[src]
impl From<AsciiChar> for char
[src]
impl FromIterator<AsciiChar> for AsciiString
[src]
fn from_iter<I: IntoIterator<Item = AsciiChar>>(iter: I) -> AsciiString
[src]
impl Hash for AsciiChar
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for AsciiChar
[src]
fn cmp(&self, other: &AsciiChar) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<AsciiChar> for AsciiChar
[src]
fn eq(&self, other: &AsciiChar) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialEq<AsciiChar> for u8
[src]
fn eq(&self, rhs: &AsciiChar) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialEq<AsciiChar> for char
[src]
fn eq(&self, rhs: &AsciiChar) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialEq<char> for AsciiChar
[src]
impl PartialEq<u8> for AsciiChar
[src]
impl PartialOrd<AsciiChar> for AsciiChar
[src]
fn partial_cmp(&self, other: &AsciiChar) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<AsciiChar> for u8
[src]
fn partial_cmp(&self, rhs: &AsciiChar) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<AsciiChar> for char
[src]
fn partial_cmp(&self, rhs: &AsciiChar) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<char> for AsciiChar
[src]
fn partial_cmp(&self, rhs: &char) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<u8> for AsciiChar
[src]
fn partial_cmp(&self, rhs: &u8) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl StructuralEq for AsciiChar
[src]
impl StructuralPartialEq for AsciiChar
[src]
impl ToAsciiChar for AsciiChar
[src]
fn to_ascii_char(self) -> Result<AsciiChar, ToAsciiCharError>
[src]
unsafe fn to_ascii_char_unchecked(self) -> AsciiChar
[src]
Auto Trait Implementations
impl RefUnwindSafe for AsciiChar
impl Send for AsciiChar
impl Sync for AsciiChar
impl Unpin for AsciiChar
impl UnwindSafe for AsciiChar
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,