Skip to content

Commit 7b96f13

Browse files
committed
std::ascii: Fix is_digit() and is_control()
is_digit() incorrectly returned false for '0'. is_control() incorrectly returned true for ' ' (space).
1 parent 18687a9 commit 7b96f13

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libstd/ascii.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl Ascii {
6767
/// Check if the character is a number (0-9)
6868
#[inline]
6969
pub fn is_digit(&self) -> bool {
70-
self.chr >= 0x31 && self.chr <= 0x39
70+
self.chr >= 0x30 && self.chr <= 0x39
7171
}
7272

7373
/// Check if the character is a letter or number
@@ -85,7 +85,7 @@ impl Ascii {
8585
/// Check if the character is a control character
8686
#[inline]
8787
pub fn is_control(&self) -> bool {
88-
self.chr <= 0x20 || self.chr == 0x7F
88+
self.chr < 0x20 || self.chr == 0x7F
8989
}
9090

9191
/// Checks if the character is printable (except space)

0 commit comments

Comments
 (0)