Skip to content

Commit 65ffc77

Browse files
tormolThomas Bahn
authored andcommitted
Fix inconstistencies
* Make methods const fn and #[inline] even if just a different name for another method. * Make all is_ascii_xxx() methods take self by reference.
1 parent 31316c7 commit 65ffc77

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/ascii_char.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,8 @@ impl AsciiChar {
404404
/// Check if the character is a letter (a-z, A-Z).
405405
///
406406
/// This method is identical to [`is_alphabetic()`](#method.is_alphabetic)
407-
pub fn is_ascii_alphabetic(&self) -> bool {
407+
#[inline]
408+
pub const fn is_ascii_alphabetic(&self) -> bool {
408409
self.is_alphabetic()
409410
}
410411

@@ -452,7 +453,8 @@ impl AsciiChar {
452453
/// Check if the character is a letter or number
453454
///
454455
/// This method is identical to [`is_alphanumeric()`](#method.is_alphanumeric)
455-
pub fn is_ascii_alphanumeric(&self) -> bool {
456+
#[inline]
457+
pub const fn is_ascii_alphanumeric(&self) -> bool {
456458
self.is_alphanumeric()
457459
}
458460

@@ -469,8 +471,8 @@ impl AsciiChar {
469471
/// assert!(!AsciiChar::FF.is_ascii_blank());
470472
/// ```
471473
#[inline]
472-
pub const fn is_ascii_blank(self) -> bool {
473-
(self as u8 == b' ') | (self as u8 == b'\t')
474+
pub const fn is_ascii_blank(&self) -> bool {
475+
(*self as u8 == b' ') | (*self as u8 == b'\t')
474476
}
475477

476478
/// Check if the character one of ' ', '\t', '\n', '\r',
@@ -485,8 +487,10 @@ impl AsciiChar {
485487
///
486488
/// This method is NOT identical to `is_whitespace()`.
487489
#[inline]
488-
pub const fn is_ascii_whitespace(self) -> bool {
489-
self.is_ascii_blank() | (self as u8 == b'\n') | (self as u8 == b'\r') | (self as u8 == 0x0c)
490+
pub const fn is_ascii_whitespace(&self) -> bool {
491+
self.is_ascii_blank()
492+
| (*self as u8 == b'\n') | (*self as u8 == b'\r')
493+
| (*self as u8 == 0x0c/*form feed*/)
490494
}
491495

492496
/// Check if the character is a control character
@@ -551,7 +555,8 @@ impl AsciiChar {
551555
/// Checks if the character is alphabetic and lowercase (a-z).
552556
///
553557
/// This method is identical to [`is_lowercase()`](#method.is_lowercase)
554-
pub fn is_ascii_lowercase(&self) -> bool {
558+
#[inline]
559+
pub const fn is_ascii_lowercase(&self) -> bool {
555560
self.is_lowercase()
556561
}
557562

@@ -572,7 +577,8 @@ impl AsciiChar {
572577
/// Checks if the character is alphabetic and uppercase (A-Z).
573578
///
574579
/// This method is identical to [`is_uppercase()`](#method.is_uppercase)
575-
pub fn is_ascii_uppercase(&self) -> bool {
580+
#[inline]
581+
pub const fn is_ascii_uppercase(&self) -> bool {
576582
self.is_uppercase()
577583
}
578584

0 commit comments

Comments
 (0)