@@ -305,48 +305,48 @@ impl AsciiChar {
305
305
306
306
/// Converts an ASCII character into a `u8`.
307
307
#[ inline]
308
- pub fn as_byte ( & self ) -> u8 {
309
- * self as u8
308
+ pub fn as_byte ( self ) -> u8 {
309
+ self as u8
310
310
}
311
311
312
312
/// Converts an ASCII character into a `char`.
313
313
#[ inline]
314
- pub fn as_char ( & self ) -> char {
314
+ pub fn as_char ( self ) -> char {
315
315
self . as_byte ( ) as char
316
316
}
317
317
318
318
// the following methods are like ctype, and the implementation is inspired by musl
319
319
320
320
/// Check if the character is a letter (a-z, A-Z)
321
321
#[ inline]
322
- pub fn is_alphabetic ( & self ) -> bool {
322
+ pub fn is_alphabetic ( self ) -> bool {
323
323
let c = self . as_byte ( ) | 0b010_0000 ; // Turns uppercase into lowercase.
324
324
c >= b'a' && c <= b'z'
325
325
}
326
326
327
327
/// Check if the character is a number (0-9)
328
328
#[ inline]
329
- pub fn is_digit ( & self ) -> bool {
330
- self >= & AsciiChar :: _0 && self <= & AsciiChar :: _9
329
+ pub fn is_digit ( self ) -> bool {
330
+ self >= AsciiChar :: _0 && self <= AsciiChar :: _9
331
331
}
332
332
333
333
/// Check if the character is a letter or number
334
334
#[ inline]
335
- pub fn is_alphanumeric ( & self ) -> bool {
335
+ pub fn is_alphanumeric ( self ) -> bool {
336
336
self . is_alphabetic ( ) || self . is_digit ( )
337
337
}
338
338
339
339
/// Check if the character is a space or horizontal tab
340
340
#[ inline]
341
- pub fn is_blank ( & self ) -> bool {
342
- * self == AsciiChar :: Space || * self == AsciiChar :: Tab
341
+ pub fn is_blank ( self ) -> bool {
342
+ self == AsciiChar :: Space || self == AsciiChar :: Tab
343
343
}
344
344
345
345
/// Check if the character is a ' ', '\t', '\n' or '\r'
346
346
#[ inline]
347
- pub fn is_whitespace ( & self ) -> bool {
348
- self . is_blank ( ) || * self == AsciiChar :: LineFeed
349
- || * self == AsciiChar :: CarriageReturn
347
+ pub fn is_whitespace ( self ) -> bool {
348
+ self . is_blank ( ) || self == AsciiChar :: LineFeed
349
+ || self == AsciiChar :: CarriageReturn
350
350
}
351
351
352
352
/// Check if the character is a control character
@@ -360,8 +360,8 @@ impl AsciiChar {
360
360
/// assert_eq!('\n'.to_ascii_char().unwrap().is_control(), true);
361
361
/// ```
362
362
#[ inline]
363
- pub fn is_control ( & self ) -> bool {
364
- * self < AsciiChar :: Space || * self == AsciiChar :: DEL
363
+ pub fn is_control ( self ) -> bool {
364
+ self < AsciiChar :: Space || self == AsciiChar :: DEL
365
365
}
366
366
367
367
/// Checks if the character is printable (except space)
@@ -374,7 +374,7 @@ impl AsciiChar {
374
374
/// assert_eq!('\n'.to_ascii_char().unwrap().is_graph(), false);
375
375
/// ```
376
376
#[ inline]
377
- pub fn is_graph ( & self ) -> bool {
377
+ pub fn is_graph ( self ) -> bool {
378
378
self . as_byte ( ) . wrapping_sub ( b' ' +1 ) < 0x5E
379
379
}
380
380
@@ -388,7 +388,7 @@ impl AsciiChar {
388
388
/// assert_eq!('\n'.to_ascii_char().unwrap().is_print(), false);
389
389
/// ```
390
390
#[ inline]
391
- pub fn is_print ( & self ) -> bool {
391
+ pub fn is_print ( self ) -> bool {
392
392
self . as_byte ( ) . wrapping_sub ( b' ' ) < 0x5F
393
393
}
394
394
@@ -402,7 +402,7 @@ impl AsciiChar {
402
402
/// assert_eq!('@'.to_ascii_char().unwrap().is_lowercase(), false);
403
403
/// ```
404
404
#[ inline]
405
- pub fn is_lowercase ( & self ) -> bool {
405
+ pub fn is_lowercase ( self ) -> bool {
406
406
self . as_byte ( ) . wrapping_sub ( b'a' ) < 26
407
407
}
408
408
@@ -416,7 +416,7 @@ impl AsciiChar {
416
416
/// assert_eq!('@'.to_ascii_char().unwrap().is_uppercase(), false);
417
417
/// ```
418
418
#[ inline]
419
- pub fn is_uppercase ( & self ) -> bool {
419
+ pub fn is_uppercase ( self ) -> bool {
420
420
self . as_byte ( ) . wrapping_sub ( b'A' ) < 26
421
421
}
422
422
@@ -431,7 +431,7 @@ impl AsciiChar {
431
431
/// assert_eq!('~'.to_ascii_char().unwrap().is_punctuation(), true);
432
432
/// ```
433
433
#[ inline]
434
- pub fn is_punctuation ( & self ) -> bool {
434
+ pub fn is_punctuation ( self ) -> bool {
435
435
self . is_graph ( ) && !self . is_alphanumeric ( )
436
436
}
437
437
@@ -447,7 +447,7 @@ impl AsciiChar {
447
447
/// assert_eq!(' '.to_ascii_char().unwrap().is_hex(), false);
448
448
/// ```
449
449
#[ inline]
450
- pub fn is_hex ( & self ) -> bool {
450
+ pub fn is_hex ( self ) -> bool {
451
451
self . is_digit ( ) || ( self . as_byte ( ) | 0x20u8 ) . wrapping_sub ( b'a' ) < 6
452
452
}
453
453
@@ -551,27 +551,27 @@ impl AsciiExt for AsciiChar {
551
551
macro_rules! impl_into_partial_eq_ord { ( $wider: ty, $to_wider: expr) => {
552
552
impl From <AsciiChar > for $wider {
553
553
fn from( a: AsciiChar ) -> $wider {
554
- $to_wider( & a)
554
+ $to_wider( a)
555
555
}
556
556
}
557
557
impl PartialEq <$wider> for AsciiChar {
558
558
fn eq( & self , rhs: & $wider) -> bool {
559
- $to_wider( self ) == * rhs
559
+ $to_wider( * self ) == * rhs
560
560
}
561
561
}
562
562
impl PartialEq <AsciiChar > for $wider {
563
563
fn eq( & self , rhs: & AsciiChar ) -> bool {
564
- * self == $to_wider( rhs)
564
+ * self == $to_wider( * rhs)
565
565
}
566
566
}
567
567
impl PartialOrd <$wider> for AsciiChar {
568
568
fn partial_cmp( & self , rhs: & $wider) -> Option <Ordering > {
569
- $to_wider( self ) . partial_cmp( rhs)
569
+ $to_wider( * self ) . partial_cmp( rhs)
570
570
}
571
571
}
572
572
impl PartialOrd <AsciiChar > for $wider {
573
573
fn partial_cmp( & self , rhs: & AsciiChar ) -> Option <Ordering > {
574
- self . partial_cmp( & $to_wider( rhs) )
574
+ self . partial_cmp( & $to_wider( * rhs) )
575
575
}
576
576
}
577
577
} }
0 commit comments