@@ -209,7 +209,7 @@ pub trait Char {
209
209
///
210
210
/// Fails if given a radix > 36.
211
211
#[ deprecated = "use is_digit" ]
212
- fn is_digit_radix ( & self , radix : uint ) -> bool ;
212
+ fn is_digit_radix ( self , radix : uint ) -> bool ;
213
213
214
214
/// Checks if a `char` parses as a numeric digit in the given radix.
215
215
///
@@ -225,7 +225,7 @@ pub trait Char {
225
225
///
226
226
/// Fails if given a radix > 36.
227
227
#[ unstable = "pending error conventions" ]
228
- fn is_digit ( & self , radix : uint ) -> bool ;
228
+ fn is_digit ( self , radix : uint ) -> bool ;
229
229
230
230
/// Converts a character to the corresponding digit.
231
231
///
@@ -239,7 +239,7 @@ pub trait Char {
239
239
///
240
240
/// Fails if given a radix outside the range [0..36].
241
241
#[ unstable = "pending error conventions, trait organization" ]
242
- fn to_digit ( & self , radix : uint ) -> Option < uint > ;
242
+ fn to_digit ( self , radix : uint ) -> Option < uint > ;
243
243
244
244
/// Converts a number to the character representing it.
245
245
///
@@ -266,7 +266,7 @@ pub trait Char {
266
266
/// * Characters in [0x100,0xffff] get 4-digit escapes: `\\uNNNN`.
267
267
/// * Characters above 0x10000 get 8-digit escapes: `\\UNNNNNNNN`.
268
268
#[ unstable = "pending error conventions, trait organization" ]
269
- fn escape_unicode ( & self , f: |char|) ;
269
+ fn escape_unicode ( self , f: |char|) ;
270
270
271
271
/// Returns a 'default' ASCII and C++11-like literal escape of a
272
272
/// character.
@@ -281,22 +281,22 @@ pub trait Char {
281
281
/// * Any other chars in the range [0x20,0x7e] are not escaped.
282
282
/// * Any other chars are given hex Unicode escapes; see `escape_unicode`.
283
283
#[ unstable = "pending error conventions, trait organization" ]
284
- fn escape_default ( & self , f: |char|) ;
284
+ fn escape_default ( self , f: |char|) ;
285
285
286
286
/// Returns the amount of bytes this character would need if encoded in
287
287
/// UTF-8.
288
288
#[ deprecated = "use len_utf8" ]
289
- fn len_utf8_bytes ( & self ) -> uint ;
289
+ fn len_utf8_bytes ( self ) -> uint ;
290
290
291
291
/// Returns the amount of bytes this character would need if encoded in
292
292
/// UTF-8.
293
293
#[ unstable = "pending trait organization" ]
294
- fn len_utf8 ( & self ) -> uint ;
294
+ fn len_utf8 ( self ) -> uint ;
295
295
296
296
/// Returns the amount of bytes this character would need if encoded in
297
297
/// UTF-16.
298
298
#[ unstable = "pending trait organization" ]
299
- fn len_utf16 ( & self ) -> uint ;
299
+ fn len_utf16 ( self ) -> uint ;
300
300
301
301
/// Encodes this character as UTF-8 into the provided byte buffer,
302
302
/// and then returns the number of bytes written.
@@ -318,25 +318,25 @@ pub trait Char {
318
318
#[ experimental = "trait is experimental" ]
319
319
impl Char for char {
320
320
#[ deprecated = "use is_digit" ]
321
- fn is_digit_radix ( & self , radix : uint ) -> bool { self . is_digit ( radix) }
321
+ fn is_digit_radix ( self , radix : uint ) -> bool { self . is_digit ( radix) }
322
322
323
323
#[ unstable = "pending trait organization" ]
324
- fn is_digit ( & self , radix : uint ) -> bool {
324
+ fn is_digit ( self , radix : uint ) -> bool {
325
325
match self . to_digit ( radix) {
326
326
Some ( _) => true ,
327
327
None => false ,
328
328
}
329
329
}
330
330
331
331
#[ unstable = "pending trait organization" ]
332
- fn to_digit ( & self , radix : uint ) -> Option < uint > {
332
+ fn to_digit ( self , radix : uint ) -> Option < uint > {
333
333
if radix > 36 {
334
334
panic ! ( "to_digit: radix is too high (maximum 36)" ) ;
335
335
}
336
- let val = match * self {
337
- '0' ... '9' => * self as uint - ( '0' as uint ) ,
338
- 'a' ... 'z' => * self as uint + 10 u - ( 'a' as uint ) ,
339
- 'A' ... 'Z' => * self as uint + 10 u - ( 'A' as uint ) ,
336
+ let val = match self {
337
+ '0' ... '9' => self as uint - ( '0' as uint ) ,
338
+ 'a' ... 'z' => self as uint + 10 u - ( 'a' as uint ) ,
339
+ 'A' ... 'Z' => self as uint + 10 u - ( 'A' as uint ) ,
340
340
_ => return None ,
341
341
} ;
342
342
if val < radix { Some ( val) }
@@ -351,19 +351,19 @@ impl Char for char {
351
351
fn from_u32 ( i : u32 ) -> Option < char > { from_u32 ( i) }
352
352
353
353
#[ unstable = "pending error conventions, trait organization" ]
354
- fn escape_unicode ( & self , f: |char|) {
354
+ fn escape_unicode ( self , f: |char|) {
355
355
// avoid calling str::to_str_radix because we don't really need to allocate
356
356
// here.
357
357
f ( '\\' ) ;
358
358
let pad = match ( ) {
359
- _ if * self <= '\xff' => { f ( 'x' ) ; 2 }
360
- _ if * self <= '\uffff' => { f ( 'u' ) ; 4 }
359
+ _ if self <= '\xff' => { f ( 'x' ) ; 2 }
360
+ _ if self <= '\uffff' => { f ( 'u' ) ; 4 }
361
361
_ => { f ( 'U' ) ; 8 }
362
362
} ;
363
363
for offset in range_step :: < i32 > ( 4 * ( pad - 1 ) , -1 , -4 ) {
364
364
let offset = offset as uint ;
365
365
unsafe {
366
- match ( ( * self as i32 ) >> offset) & 0xf {
366
+ match ( ( self as i32 ) >> offset) & 0xf {
367
367
i @ 0 ... 9 => { f ( transmute ( '0' as i32 + i) ) ; }
368
368
i => { f ( transmute ( 'a' as i32 + ( i - 10 ) ) ) ; }
369
369
}
@@ -372,27 +372,27 @@ impl Char for char {
372
372
}
373
373
374
374
#[ unstable = "pending error conventions, trait organization" ]
375
- fn escape_default ( & self , f: |char|) {
376
- match * self {
375
+ fn escape_default ( self , f: |char|) {
376
+ match self {
377
377
'\t' => { f ( '\\' ) ; f ( 't' ) ; }
378
378
'\r' => { f ( '\\' ) ; f ( 'r' ) ; }
379
379
'\n' => { f ( '\\' ) ; f ( 'n' ) ; }
380
380
'\\' => { f ( '\\' ) ; f ( '\\' ) ; }
381
381
'\'' => { f ( '\\' ) ; f ( '\'' ) ; }
382
382
'"' => { f ( '\\' ) ; f ( '"' ) ; }
383
- '\x20' ... '\x7e' => { f ( * self ) ; }
383
+ '\x20' ... '\x7e' => { f ( self ) ; }
384
384
_ => self . escape_unicode ( f) ,
385
385
}
386
386
}
387
387
388
388
#[ inline]
389
389
#[ deprecated = "use len_utf8" ]
390
- fn len_utf8_bytes ( & self ) -> uint { self . len_utf8 ( ) }
390
+ fn len_utf8_bytes ( self ) -> uint { self . len_utf8 ( ) }
391
391
392
392
#[ inline]
393
393
#[ unstable = "pending trait organization" ]
394
- fn len_utf8 ( & self ) -> uint {
395
- let code = * self as u32 ;
394
+ fn len_utf8 ( self ) -> uint {
395
+ let code = self as u32 ;
396
396
match ( ) {
397
397
_ if code < MAX_ONE_B => 1 u,
398
398
_ if code < MAX_TWO_B => 2 u,
@@ -403,8 +403,8 @@ impl Char for char {
403
403
404
404
#[ inline]
405
405
#[ unstable = "pending trait organization" ]
406
- fn len_utf16 ( & self ) -> uint {
407
- let ch = * self as u32 ;
406
+ fn len_utf16 ( self ) -> uint {
407
+ let ch = self as u32 ;
408
408
if ( ch & 0xFFFF_u32 ) == ch { 1 } else { 2 }
409
409
}
410
410
0 commit comments