Skip to content

Commit 71dc166

Browse files
committed
---
yaml --- r: 14214 b: refs/heads/try c: b3444db h: refs/heads/master v: v3
1 parent 7b43618 commit 71dc166

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
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: 4339307359eaca1ae1fd5de96eec746e96a90564
5+
refs/heads/try: b3444db1614a85afd9f306459595c2870a6b2047
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/libcore/char.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export is_alphabetic,
3737
is_XID_start, is_XID_continue,
3838
is_lowercase, is_uppercase,
3939
is_whitespace, is_alphanumeric,
40+
is_ascii,
4041
to_digit, to_lower, to_upper, maybe_digit, cmp;
4142

4243
import is_alphabetic = unicode::derived_property::Alphabetic;
@@ -84,6 +85,9 @@ pure fn is_alphanumeric(c: char) -> bool {
8485
unicode::general_category::No(c);
8586
}
8687

88+
pure fn is_ascii(c: char) -> bool {
89+
c - ('\x7F' & c) == '\x00'
90+
}
8791

8892
#[doc(
8993
brief = "Convert a char to the corresponding digit. \
@@ -221,3 +225,10 @@ fn test_to_upper() {
221225
//assert (to_upper('ü') == 'Ü');
222226
assert (to_upper('ß') == 'ß');
223227
}
228+
229+
#[test]
230+
fn test_ascii() unsafe {
231+
assert str::all("banana", char::is_ascii);
232+
assert ! str::all("ประเทศไทย中华Việt Nam", char::is_ascii);
233+
}
234+

0 commit comments

Comments
 (0)