@@ -69,7 +69,7 @@ pub const MAX: char = '\u{10ffff}';
69
69
70
70
/// Converts from `u32` to a `char`
71
71
#[ inline]
72
- #[ unstable = "pending decisions about costructors for primitives" ]
72
+ #[ stable ]
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 decisions about costructors for primitives " ]
95
+ #[ unstable = "pending integer conventions " ]
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
- #[ experimental = "trait organization may change" ]
115
- pub trait Char {
114
+ #[ stable ]
115
+ pub trait CharExt {
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 Char {
126
126
/// # Panics
127
127
///
128
128
/// Panics if given a radix > 36.
129
- #[ unstable = "pending error conventions" ]
129
+ #[ unstable = "pending integer 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 Char {
140
140
/// # Panics
141
141
///
142
142
/// Panics if given a radix outside the range [0..36].
143
- #[ unstable = "pending error conventions, trait organization " ]
143
+ #[ unstable = "pending integer conventions" ]
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 Char {
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
- #[ unstable = "pending error conventions, trait organization" ]
152
+ #[ stable ]
153
153
fn escape_unicode ( self ) -> EscapeUnicode ;
154
154
155
155
/// Returns an iterator that yields the 'default' ASCII and
@@ -164,47 +164,44 @@ pub trait Char {
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
- #[ unstable = "pending error conventions, trait organization" ]
167
+ #[ stable ]
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
- #[ unstable = "pending trait organization" ]
172
+ #[ stable ]
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
- #[ unstable = "pending trait organization" ]
177
+ #[ stable ]
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
- #[ unstable = "pending trait organization" ]
186
- fn encode_utf8 ( & self , dst : & mut [ u8 ] ) -> Option < uint > ;
185
+ #[ stable ]
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
- #[ unstable = "pending trait organization" ]
194
- fn encode_utf16 ( & self , dst : & mut [ u16 ] ) -> Option < uint > ;
193
+ #[ stable ]
194
+ fn encode_utf16 ( self , dst : & mut [ u16 ] ) -> Option < uint > ;
195
195
}
196
196
197
- #[ experimental = "trait is experimental" ]
198
- impl Char for char {
199
- #[ unstable = "pending trait organization " ]
197
+ #[ stable ]
198
+ impl CharExt for char {
199
+ #[ unstable = "pending integer conventions " ]
200
200
fn is_digit ( self , radix : uint ) -> bool {
201
- match self . to_digit ( radix) {
202
- Some ( _) => true ,
203
- None => false ,
204
- }
201
+ self . to_digit ( radix) . is_some ( )
205
202
}
206
203
207
- #[ unstable = "pending trait organization " ]
204
+ #[ unstable = "pending integer conventions " ]
208
205
fn to_digit ( self , radix : uint ) -> Option < uint > {
209
206
if radix > 36 {
210
207
panic ! ( "to_digit: radix is too high (maximum 36)" ) ;
@@ -219,12 +216,12 @@ impl Char for char {
219
216
else { None }
220
217
}
221
218
222
- #[ unstable = "pending error conventions, trait organization" ]
219
+ #[ stable ]
223
220
fn escape_unicode ( self ) -> EscapeUnicode {
224
221
EscapeUnicode { c : self , state : EscapeUnicodeState :: Backslash }
225
222
}
226
223
227
- #[ unstable = "pending error conventions, trait organization" ]
224
+ #[ stable ]
228
225
fn escape_default ( self ) -> EscapeDefault {
229
226
let init_state = match self {
230
227
'\t' => EscapeDefaultState :: Backslash ( 't' ) ,
@@ -240,7 +237,7 @@ impl Char for char {
240
237
}
241
238
242
239
#[ inline]
243
- #[ unstable = "pending trait organization" ]
240
+ #[ stable ]
244
241
fn len_utf8 ( self ) -> uint {
245
242
let code = self as u32 ;
246
243
match ( ) {
@@ -252,17 +249,17 @@ impl Char for char {
252
249
}
253
250
254
251
#[ inline]
255
- #[ unstable = "pending trait organization" ]
252
+ #[ stable ]
256
253
fn len_utf16 ( self ) -> uint {
257
254
let ch = self as u32 ;
258
255
if ( ch & 0xFFFF_u32 ) == ch { 1 } else { 2 }
259
256
}
260
257
261
258
#[ inline]
262
- #[ unstable = "pending error conventions, trait organization " ]
263
- fn encode_utf8 < ' a > ( & self , dst : & ' a mut [ u8 ] ) -> Option < uint > {
259
+ #[ unstable = "pending decision about Iterator/Writer/Reader " ]
260
+ fn encode_utf8 ( self , dst : & mut [ u8 ] ) -> Option < uint > {
264
261
// Marked #[inline] to allow llvm optimizing it away
265
- let code = * self as u32 ;
262
+ let code = self as u32 ;
266
263
if code < MAX_ONE_B && dst. len ( ) >= 1 {
267
264
dst[ 0 ] = code as u8 ;
268
265
Some ( 1 )
@@ -287,10 +284,10 @@ impl Char for char {
287
284
}
288
285
289
286
#[ inline]
290
- #[ unstable = "pending error conventions, trait organization " ]
291
- fn encode_utf16 ( & self , dst : & mut [ u16 ] ) -> Option < uint > {
287
+ #[ unstable = "pending decision about Iterator/Writer/Reader " ]
288
+ fn encode_utf16 ( self , dst : & mut [ u16 ] ) -> Option < uint > {
292
289
// Marked #[inline] to allow llvm optimizing it away
293
- let mut ch = * self as u32 ;
290
+ let mut ch = self as u32 ;
294
291
if ( ch & 0xFFFF_u32 ) == ch && dst. len ( ) >= 1 {
295
292
// The BMP falls through (assuming non-surrogate, as it should)
296
293
dst[ 0 ] = ch as u16 ;
@@ -310,6 +307,7 @@ impl Char for char {
310
307
/// An iterator over the characters that represent a `char`, as escaped by
311
308
/// Rust's unicode escaping rules.
312
309
#[ derive( Clone ) ]
310
+ #[ stable]
313
311
pub struct EscapeUnicode {
314
312
c : char ,
315
313
state : EscapeUnicodeState
@@ -325,6 +323,7 @@ enum EscapeUnicodeState {
325
323
Done ,
326
324
}
327
325
326
+ #[ stable]
328
327
impl Iterator for EscapeUnicode {
329
328
type Item = char ;
330
329
@@ -370,6 +369,7 @@ impl Iterator for EscapeUnicode {
370
369
/// An iterator over the characters that represent a `char`, escaped
371
370
/// for maximum portability.
372
371
#[ derive( Clone ) ]
372
+ #[ stable]
373
373
pub struct EscapeDefault {
374
374
state : EscapeDefaultState
375
375
}
@@ -382,6 +382,7 @@ enum EscapeDefaultState {
382
382
Unicode ( EscapeUnicode ) ,
383
383
}
384
384
385
+ #[ stable]
385
386
impl Iterator for EscapeDefault {
386
387
type Item = char ;
387
388
0 commit comments