-
Couldn't load subscription status.
- Fork 24
Description
Proposal
Problem statement
Add useful things to core::ascii::Char:
- Add
MINandMAXconstants. - Add ASCII-related methods from
u8.
Motivating examples or use cases
It would be nice if MIN and MAX existed for consistency with other ordered types and for things like iterating over MIN..=MAX. It would also be nice if ascii::Char was at feature parity with u8-as-ASCII so that the relevant methods can be used in cases where they are needed.
Solution sketch
pub const MIN: Self = Self::Null;
pub const MAX: Self = Self::Delete;
pub const fn to_ascii_uppercase(&self) -> Self
pub const fn to_ascii_lowercase(&self) -> Self
pub const fn eq_ignore_ascii_case(&self, other: &Self) -> bool
pub const fn make_ascii_uppercase(&mut self)
pub const fn make_ascii_lowercase(&mut self)
pub const fn is_ascii(&self) -> bool // Returns `true`
pub const fn is_ascii_alphabetic(&self) -> bool
pub const fn is_ascii_uppercase(&self) -> bool
pub const fn is_ascii_lowercase(&self) -> bool
pub const fn is_ascii_alphanumeric(&self) -> bool
pub const fn is_ascii_digit(&self) -> bool
pub const fn is_ascii_octdigit(&self) -> bool
pub const fn is_ascii_hexdigit(&self) -> bool
pub const fn is_ascii_punctuation(&self) -> bool
pub const fn is_ascii_graphic(&self) -> bool
pub const fn is_ascii_whitespace(&self) -> bool
pub const fn is_ascii_control(&self) -> bool
pub fn escape_ascii(self) -> super::EscapeDefaultAlternatives
The following alternatives are possible. I don't feel strongly one way or the other:
&selfarguments could be changed toself.- The
is_asciimethod can be deleted. asciicould be removed from the method names.
I used &self for consistency with char and u8 is_ascii* methods, which take &self. I included fn is_ascii and added the methods with ascii in the names so that a subset of code can be written that works for ascii::Char, u8, and char in macros and so that converting code from u8 to ascii::Char would be easier.