@@ -20,12 +20,9 @@ use tables::{derived_property, property, general_category, conversions, charwidt
20
20
21
21
/// Returns whether the specified `char` is considered a Unicode alphabetic
22
22
/// code point
23
+ #[ deprecated = "use UnicodeChar::is_alphabetic" ]
23
24
pub fn is_alphabetic ( c : char ) -> bool {
24
- match c {
25
- 'a' ... 'z' | 'A' ... 'Z' => true ,
26
- c if c > '\x7f' => derived_property:: Alphabetic ( c) ,
27
- _ => false
28
- }
25
+ c. is_alphabetic ( )
29
26
}
30
27
31
28
/// Returns whether the specified `char` satisfies the 'XID_Start' Unicode property
@@ -34,6 +31,7 @@ pub fn is_alphabetic(c: char) -> bool {
34
31
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
35
32
/// mostly similar to ID_Start but modified for closure under NFKx.
36
33
#[ allow( non_snake_case) ]
34
+ #[ deprecated = "use UnicodeChar::is_XID_start" ]
37
35
pub fn is_XID_start ( c : char ) -> bool { derived_property:: XID_Start ( c) }
38
36
39
37
/// Returns whether the specified `char` satisfies the 'XID_Continue' Unicode property
@@ -42,6 +40,7 @@ pub fn is_XID_start(c: char) -> bool { derived_property::XID_Start(c) }
42
40
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
43
41
/// mostly similar to 'ID_Continue' but modified for closure under NFKx.
44
42
#[ allow( non_snake_case) ]
43
+ #[ deprecated = "use UnicodeChar::is_XID_continue" ]
45
44
pub fn is_XID_continue ( c : char ) -> bool { derived_property:: XID_Continue ( c) }
46
45
47
46
///
@@ -50,12 +49,9 @@ pub fn is_XID_continue(c: char) -> bool { derived_property::XID_Continue(c) }
50
49
/// This is defined according to the terms of the Unicode Derived Core Property 'Lowercase'.
51
50
///
52
51
#[ inline]
52
+ #[ deprecated = "use UnicodeChar::is_lowercase" ]
53
53
pub fn is_lowercase ( c : char ) -> bool {
54
- match c {
55
- 'a' ... 'z' => true ,
56
- c if c > '\x7f' => derived_property:: Lowercase ( c) ,
57
- _ => false
58
- }
54
+ c. is_lowercase ( )
59
55
}
60
56
61
57
///
@@ -64,12 +60,9 @@ pub fn is_lowercase(c: char) -> bool {
64
60
/// This is defined according to the terms of the Unicode Derived Core Property 'Uppercase'.
65
61
///
66
62
#[ inline]
63
+ #[ deprecated = "use UnicodeChar::is_uppercase" ]
67
64
pub fn is_uppercase ( c : char ) -> bool {
68
- match c {
69
- 'A' ... 'Z' => true ,
70
- c if c > '\x7f' => derived_property:: Uppercase ( c) ,
71
- _ => false
72
- }
65
+ c. is_uppercase ( )
73
66
}
74
67
75
68
///
@@ -78,12 +71,9 @@ pub fn is_uppercase(c: char) -> bool {
78
71
/// Whitespace is defined in terms of the Unicode Property 'White_Space'.
79
72
///
80
73
#[ inline]
74
+ #[ deprecated = "use UnicodeChar::is_whitespace" ]
81
75
pub fn is_whitespace ( c : char ) -> bool {
82
- match c {
83
- ' ' | '\x09' ... '\x0d' => true ,
84
- c if c > '\x7f' => property:: White_Space ( c) ,
85
- _ => false
86
- }
76
+ c. is_whitespace ( )
87
77
}
88
78
89
79
///
@@ -93,9 +83,9 @@ pub fn is_whitespace(c: char) -> bool {
93
83
/// 'Nd', 'Nl', 'No' and the Derived Core Property 'Alphabetic'.
94
84
///
95
85
#[ inline]
86
+ #[ deprecated = "use UnicodeChar::is_alphanumeric" ]
96
87
pub fn is_alphanumeric ( c : char ) -> bool {
97
- is_alphabetic ( c)
98
- || is_digit ( c)
88
+ c. is_alphanumeric ( )
99
89
}
100
90
101
91
///
@@ -105,16 +95,14 @@ pub fn is_alphanumeric(c: char) -> bool {
105
95
/// 'Cc'.
106
96
///
107
97
#[ inline]
98
+ #[ deprecated = "use UnicodeChar::is_control" ]
108
99
pub fn is_control ( c : char ) -> bool { general_category:: Cc ( c) }
109
100
110
101
/// Indicates whether the `char` is numeric (Nd, Nl, or No)
111
102
#[ inline]
103
+ #[ deprecated = "use UnicodeChar::is_numeric" ]
112
104
pub fn is_digit ( c : char ) -> bool {
113
- match c {
114
- '0' ... '9' => true ,
115
- c if c > '\x7f' => general_category:: N ( c) ,
116
- _ => false
117
- }
105
+ c. is_numeric ( )
118
106
}
119
107
120
108
/// Convert a char to its uppercase equivalent
@@ -132,6 +120,7 @@ pub fn is_digit(c: char) -> bool {
132
120
///
133
121
/// Returns the char itself if no conversion was made
134
122
#[ inline]
123
+ #[ deprecated = "use UnicodeChar::to_uppercase" ]
135
124
pub fn to_uppercase ( c : char ) -> char {
136
125
conversions:: to_upper ( c)
137
126
}
@@ -145,6 +134,7 @@ pub fn to_uppercase(c: char) -> char {
145
134
///
146
135
/// Returns the char itself if no conversion if possible
147
136
#[ inline]
137
+ #[ deprecated = "use UnicodeChar::to_lowercase" ]
148
138
pub fn to_lowercase ( c : char ) -> char {
149
139
conversions:: to_lower ( c)
150
140
}
@@ -158,11 +148,13 @@ pub fn to_lowercase(c: char) -> char {
158
148
/// [Unicode Standard Annex #11](http://www.unicode.org/reports/tr11/)
159
149
/// recommends that these characters be treated as 1 column (i.e.,
160
150
/// `is_cjk` = `false`) if the context cannot be reliably determined.
151
+ #[ deprecated = "use UnicodeChar::width" ]
161
152
pub fn width ( c : char , is_cjk : bool ) -> Option < uint > {
162
153
charwidth:: width ( c, is_cjk)
163
154
}
164
155
165
156
/// Useful functions for Unicode characters.
157
+ #[ experimental = "pending prelude organization" ]
166
158
pub trait UnicodeChar {
167
159
/// Returns whether the specified character is considered a Unicode
168
160
/// alphabetic code point.
@@ -265,29 +257,62 @@ pub trait UnicodeChar {
265
257
fn width ( self , is_cjk : bool ) -> Option < uint > ;
266
258
}
267
259
260
+ #[ experimental = "pending prelude organization" ]
268
261
impl UnicodeChar for char {
269
- fn is_alphabetic ( self ) -> bool { is_alphabetic ( self ) }
262
+ fn is_alphabetic ( self ) -> bool {
263
+ match self {
264
+ 'a' ... 'z' | 'A' ... 'Z' => true ,
265
+ c if c > '\x7f' => derived_property:: Alphabetic ( c) ,
266
+ _ => false
267
+ }
268
+ }
270
269
271
- fn is_XID_start ( self ) -> bool { is_XID_start ( self ) }
270
+ fn is_XID_start ( self ) -> bool { derived_property :: XID_Start ( self ) }
272
271
273
- fn is_XID_continue ( self ) -> bool { is_XID_continue ( self ) }
272
+ fn is_XID_continue ( self ) -> bool { derived_property :: XID_Continue ( self ) }
274
273
275
- fn is_lowercase ( self ) -> bool { is_lowercase ( self ) }
274
+ fn is_lowercase ( self ) -> bool {
275
+ match self {
276
+ 'a' ... 'z' => true ,
277
+ c if c > '\x7f' => derived_property:: Lowercase ( c) ,
278
+ _ => false
279
+ }
280
+ }
276
281
277
- fn is_uppercase ( self ) -> bool { is_uppercase ( self ) }
282
+ fn is_uppercase ( self ) -> bool {
283
+ match self {
284
+ 'A' ... 'Z' => true ,
285
+ c if c > '\x7f' => derived_property:: Uppercase ( c) ,
286
+ _ => false
287
+ }
288
+ }
278
289
279
- fn is_whitespace ( self ) -> bool { is_whitespace ( self ) }
290
+ fn is_whitespace ( self ) -> bool {
291
+ match self {
292
+ ' ' | '\x09' ... '\x0d' => true ,
293
+ c if c > '\x7f' => property:: White_Space ( c) ,
294
+ _ => false
295
+ }
296
+ }
280
297
281
- fn is_alphanumeric ( self ) -> bool { is_alphanumeric ( self ) }
298
+ fn is_alphanumeric ( self ) -> bool {
299
+ self . is_alphabetic ( ) || self . is_numeric ( )
300
+ }
282
301
283
- fn is_control ( self ) -> bool { is_control ( self ) }
302
+ fn is_control ( self ) -> bool { general_category :: Cc ( self ) }
284
303
285
- fn is_numeric ( self ) -> bool { is_digit ( self ) }
304
+ fn is_numeric ( self ) -> bool {
305
+ match self {
306
+ '0' ... '9' => true ,
307
+ c if c > '\x7f' => general_category:: N ( c) ,
308
+ _ => false
309
+ }
310
+ }
286
311
287
- fn to_lowercase ( self ) -> char { to_lowercase ( self ) }
312
+ fn to_lowercase ( self ) -> char { conversions :: to_lower ( self ) }
288
313
289
- fn to_uppercase ( self ) -> char { to_uppercase ( self ) }
314
+ fn to_uppercase ( self ) -> char { conversions :: to_upper ( self ) }
290
315
291
316
#[ experimental = "needs expert opinion. is_cjk flag stands out as ugly" ]
292
- fn width ( self , is_cjk : bool ) -> Option < uint > { width ( self , is_cjk) }
317
+ fn width ( self , is_cjk : bool ) -> Option < uint > { charwidth :: width ( self , is_cjk) }
293
318
}
0 commit comments