Skip to content

Commit 531c589

Browse files
committed
---
yaml --- r: 14215 b: refs/heads/try c: 5c58dde h: refs/heads/master i: 14213: 7b43618 14211: 1517dc9 14207: f09eb4b v: v3
1 parent 71dc166 commit 531c589

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: b3444db1614a85afd9f306459595c2870a6b2047
5+
refs/heads/try: 5c58dde2f84edac1c24d48c050e23278206ac7c1
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/libcore/char.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,18 @@ pure fn is_alphanumeric(c: char) -> bool {
8585
unicode::general_category::No(c);
8686
}
8787

88+
#[doc( brief = "Indicates whether the character is an ASCII character" )]
8889
pure fn is_ascii(c: char) -> bool {
8990
c - ('\x7F' & c) == '\x00'
9091
}
9192

93+
#[doc( brief = "Indicates whether the character is numeric (Nd, Nl, or No)" )]
94+
pure fn is_digit(c: char) -> bool {
95+
ret unicode::general_category::Nd(c) ||
96+
unicode::general_category::Nl(c) ||
97+
unicode::general_category::No(c);
98+
}
99+
92100
#[doc(
93101
brief = "Convert a char to the corresponding digit. \
94102
Safety note: This function fails if `c` is not a valid char",
@@ -227,8 +235,18 @@ fn test_to_upper() {
227235
}
228236

229237
#[test]
230-
fn test_ascii() unsafe {
238+
fn test_is_ascii() unsafe {
231239
assert str::all("banana", char::is_ascii);
232240
assert ! str::all("ประเทศไทย中华Việt Nam", char::is_ascii);
233241
}
234242

243+
#[test]
244+
fn test_is_digit() {
245+
assert is_digit('2');
246+
assert is_digit('7');
247+
assert ! is_digit('c');
248+
assert ! is_digit('i');
249+
assert ! is_digit('z');
250+
assert ! is_digit('Q');
251+
}
252+

0 commit comments

Comments
 (0)