File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 2
2
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5
- refs/heads/try: b3444db1614a85afd9f306459595c2870a6b2047
5
+ refs/heads/try: 5c58dde2f84edac1c24d48c050e23278206ac7c1
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
Original file line number Diff line number Diff line change @@ -85,10 +85,18 @@ pure fn is_alphanumeric(c: char) -> bool {
85
85
unicode:: general_category:: No ( c) ;
86
86
}
87
87
88
+ #[ doc( brief = "Indicates whether the character is an ASCII character" ) ]
88
89
pure fn is_ascii ( c : char ) -> bool {
89
90
c - ( '\x7F' & c) == '\x00'
90
91
}
91
92
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
+
92
100
#[ doc(
93
101
brief = "Convert a char to the corresponding digit. \
94
102
Safety note: This function fails if `c` is not a valid char",
@@ -227,8 +235,18 @@ fn test_to_upper() {
227
235
}
228
236
229
237
#[ test]
230
- fn test_ascii ( ) unsafe {
238
+ fn test_is_ascii ( ) unsafe {
231
239
assert str:: all ( "banana" , char:: is_ascii) ;
232
240
assert ! str:: all ( "ประเทศไทย中华Việt Nam" , char:: is_ascii) ;
233
241
}
234
242
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
+
You can’t perform that action at this time.
0 commit comments