@@ -69,7 +69,7 @@ pub const MAX: char = '\u{10ffff}';
69
69
70
70
/// Converts from `u32` to a `char`
71
71
#[ inline]
72
- #[ stable ]
72
+ #[ unstable = "pending decisions about costructors for primitives" ]
73
73
pub fn from_u32 ( i : u32 ) -> Option < char > {
74
74
// catch out-of-bounds and surrogates
75
75
if ( i > MAX as u32 ) || ( i >= 0xD800 && i <= 0xDFFF ) {
@@ -92,7 +92,7 @@ pub fn from_u32(i: u32) -> Option<char> {
92
92
/// Panics if given an `radix` > 36.
93
93
///
94
94
#[ inline]
95
- #[ unstable = "pending integer conventions " ]
95
+ #[ unstable = "pending decisions about costructors for primitives " ]
96
96
pub fn from_digit ( num : uint , radix : uint ) -> Option < char > {
97
97
if radix > 36 {
98
98
panic ! ( "from_digit: radix is too high (maximum 36)" ) ;
@@ -111,8 +111,8 @@ pub fn from_digit(num: uint, radix: uint) -> Option<char> {
111
111
}
112
112
113
113
/// Basic `char` manipulations.
114
- #[ stable ]
115
- pub trait CharExt {
114
+ #[ experimental = "trait organization may change" ]
115
+ pub trait Char {
116
116
/// Checks if a `char` parses as a numeric digit in the given radix.
117
117
///
118
118
/// Compared to `is_numeric()`, this function only recognizes the characters
@@ -126,7 +126,7 @@ pub trait CharExt {
126
126
/// # Panics
127
127
///
128
128
/// Panics if given a radix > 36.
129
- #[ unstable = "pending integer conventions" ]
129
+ #[ unstable = "pending error conventions" ]
130
130
fn is_digit ( self , radix : uint ) -> bool ;
131
131
132
132
/// Converts a character to the corresponding digit.
@@ -140,7 +140,7 @@ pub trait CharExt {
140
140
/// # Panics
141
141
///
142
142
/// Panics if given a radix outside the range [0..36].
143
- #[ unstable = "pending integer conventions" ]
143
+ #[ unstable = "pending error conventions, trait organization " ]
144
144
fn to_digit ( self , radix : uint ) -> Option < uint > ;
145
145
146
146
/// Returns an iterator that yields the hexadecimal Unicode escape
@@ -149,7 +149,7 @@ pub trait CharExt {
149
149
/// All characters are escaped with Rust syntax of the form `\\u{NNNN}`
150
150
/// where `NNNN` is the shortest hexadecimal representation of the code
151
151
/// point.
152
- #[ stable ]
152
+ #[ unstable = "pending error conventions, trait organization" ]
153
153
fn escape_unicode ( self ) -> EscapeUnicode ;
154
154
155
155
/// Returns an iterator that yields the 'default' ASCII and
@@ -164,44 +164,47 @@ pub trait CharExt {
164
164
/// escaped.
165
165
/// * Any other chars in the range [0x20,0x7e] are not escaped.
166
166
/// * Any other chars are given hex Unicode escapes; see `escape_unicode`.
167
- #[ stable ]
167
+ #[ unstable = "pending error conventions, trait organization" ]
168
168
fn escape_default ( self ) -> EscapeDefault ;
169
169
170
170
/// Returns the amount of bytes this character would need if encoded in
171
171
/// UTF-8.
172
- #[ stable ]
172
+ #[ unstable = "pending trait organization" ]
173
173
fn len_utf8 ( self ) -> uint ;
174
174
175
175
/// Returns the amount of bytes this character would need if encoded in
176
176
/// UTF-16.
177
- #[ stable ]
177
+ #[ unstable = "pending trait organization" ]
178
178
fn len_utf16 ( self ) -> uint ;
179
179
180
180
/// Encodes this character as UTF-8 into the provided byte buffer,
181
181
/// and then returns the number of bytes written.
182
182
///
183
183
/// If the buffer is not large enough, nothing will be written into it
184
184
/// and a `None` will be returned.
185
- #[ stable ]
186
- fn encode_utf8 ( self , dst : & mut [ u8 ] ) -> Option < uint > ;
185
+ #[ unstable = "pending trait organization" ]
186
+ fn encode_utf8 ( & self , dst : & mut [ u8 ] ) -> Option < uint > ;
187
187
188
188
/// Encodes this character as UTF-16 into the provided `u16` buffer,
189
189
/// and then returns the number of `u16`s written.
190
190
///
191
191
/// If the buffer is not large enough, nothing will be written into it
192
192
/// and a `None` will be returned.
193
- #[ stable ]
194
- fn encode_utf16 ( self , dst : & mut [ u16 ] ) -> Option < uint > ;
193
+ #[ unstable = "pending trait organization" ]
194
+ fn encode_utf16 ( & self , dst : & mut [ u16 ] ) -> Option < uint > ;
195
195
}
196
196
197
- #[ stable ]
198
- impl CharExt for char {
199
- #[ unstable = "pending integer conventions " ]
197
+ #[ experimental = "trait is experimental" ]
198
+ impl Char for char {
199
+ #[ unstable = "pending trait organization " ]
200
200
fn is_digit ( self , radix : uint ) -> bool {
201
- self . to_digit ( radix) . is_some ( )
201
+ match self . to_digit ( radix) {
202
+ Some ( _) => true ,
203
+ None => false ,
204
+ }
202
205
}
203
206
204
- #[ unstable = "pending integer conventions " ]
207
+ #[ unstable = "pending trait organization " ]
205
208
fn to_digit ( self , radix : uint ) -> Option < uint > {
206
209
if radix > 36 {
207
210
panic ! ( "to_digit: radix is too high (maximum 36)" ) ;
@@ -216,12 +219,12 @@ impl CharExt for char {
216
219
else { None }
217
220
}
218
221
219
- #[ stable ]
222
+ #[ unstable = "pending error conventions, trait organization" ]
220
223
fn escape_unicode ( self ) -> EscapeUnicode {
221
224
EscapeUnicode { c : self , state : EscapeUnicodeState :: Backslash }
222
225
}
223
226
224
- #[ stable ]
227
+ #[ unstable = "pending error conventions, trait organization" ]
225
228
fn escape_default ( self ) -> EscapeDefault {
226
229
let init_state = match self {
227
230
'\t' => EscapeDefaultState :: Backslash ( 't' ) ,
@@ -237,7 +240,7 @@ impl CharExt for char {
237
240
}
238
241
239
242
#[ inline]
240
- #[ stable ]
243
+ #[ unstable = "pending trait organization" ]
241
244
fn len_utf8 ( self ) -> uint {
242
245
let code = self as u32 ;
243
246
match ( ) {
@@ -249,17 +252,17 @@ impl CharExt for char {
249
252
}
250
253
251
254
#[ inline]
252
- #[ stable ]
255
+ #[ unstable = "pending trait organization" ]
253
256
fn len_utf16 ( self ) -> uint {
254
257
let ch = self as u32 ;
255
258
if ( ch & 0xFFFF_u32 ) == ch { 1 } else { 2 }
256
259
}
257
260
258
261
#[ inline]
259
- #[ unstable = "pending decision about Iterator/Writer/Reader " ]
260
- fn encode_utf8 ( self , dst : & mut [ u8 ] ) -> Option < uint > {
262
+ #[ unstable = "pending error conventions, trait organization " ]
263
+ fn encode_utf8 < ' a > ( & self , dst : & ' a mut [ u8 ] ) -> Option < uint > {
261
264
// Marked #[inline] to allow llvm optimizing it away
262
- let code = self as u32 ;
265
+ let code = * self as u32 ;
263
266
if code < MAX_ONE_B && dst. len ( ) >= 1 {
264
267
dst[ 0 ] = code as u8 ;
265
268
Some ( 1 )
@@ -284,10 +287,10 @@ impl CharExt for char {
284
287
}
285
288
286
289
#[ inline]
287
- #[ unstable = "pending decision about Iterator/Writer/Reader " ]
288
- fn encode_utf16 ( self , dst : & mut [ u16 ] ) -> Option < uint > {
290
+ #[ unstable = "pending error conventions, trait organization " ]
291
+ fn encode_utf16 ( & self , dst : & mut [ u16 ] ) -> Option < uint > {
289
292
// Marked #[inline] to allow llvm optimizing it away
290
- let mut ch = self as u32 ;
293
+ let mut ch = * self as u32 ;
291
294
if ( ch & 0xFFFF_u32 ) == ch && dst. len ( ) >= 1 {
292
295
// The BMP falls through (assuming non-surrogate, as it should)
293
296
dst[ 0 ] = ch as u16 ;
@@ -307,7 +310,6 @@ impl CharExt for char {
307
310
/// An iterator over the characters that represent a `char`, as escaped by
308
311
/// Rust's unicode escaping rules.
309
312
#[ derive( Clone ) ]
310
- #[ stable]
311
313
pub struct EscapeUnicode {
312
314
c : char ,
313
315
state : EscapeUnicodeState
@@ -323,7 +325,6 @@ enum EscapeUnicodeState {
323
325
Done ,
324
326
}
325
327
326
- #[ stable]
327
328
impl Iterator for EscapeUnicode {
328
329
type Item = char ;
329
330
@@ -369,7 +370,6 @@ impl Iterator for EscapeUnicode {
369
370
/// An iterator over the characters that represent a `char`, escaped
370
371
/// for maximum portability.
371
372
#[ derive( Clone ) ]
372
- #[ stable]
373
373
pub struct EscapeDefault {
374
374
state : EscapeDefaultState
375
375
}
@@ -382,7 +382,6 @@ enum EscapeDefaultState {
382
382
Unicode ( EscapeUnicode ) ,
383
383
}
384
384
385
- #[ stable]
386
385
impl Iterator for EscapeDefault {
387
386
type Item = char ;
388
387
0 commit comments