2222use std:: default:: Default ;
2323use std:: { char, mem, str} ;
2424
25- use futf:: { self , Codepoint , Meaning } ;
25+ use crate :: futf:: { self , Codepoint , Meaning } ;
2626
2727/// Implementation details.
2828///
2929/// You don't need these unless you are implementing
3030/// a new format.
3131pub mod imp {
3232 use std:: default:: Default ;
33- use std:: { iter, mem , slice} ;
33+ use std:: { iter, slice} ;
3434
3535 /// Describes how to fix up encodings when concatenating.
3636 ///
@@ -55,11 +55,6 @@ pub mod imp {
5555 }
5656 }
5757
58- #[ inline( always) ]
59- unsafe fn from_u32_unchecked ( n : u32 ) -> char {
60- mem:: transmute ( n)
61- }
62-
6358 pub struct SingleByteCharIndices < ' a > {
6459 inner : iter:: Enumerate < slice:: Iter < ' a , u8 > > ,
6560 }
@@ -71,7 +66,7 @@ pub mod imp {
7166 fn next ( & mut self ) -> Option < ( usize , char ) > {
7267 self . inner
7368 . next ( )
74- . map ( |( i, & b) | unsafe { ( i, from_u32_unchecked ( b as u32 ) ) } )
69+ . map ( |( i, & b) | unsafe { ( i, char :: from_u32_unchecked ( b as u32 ) ) } )
7570 }
7671 }
7772
@@ -293,30 +288,30 @@ unsafe impl Format for UTF8 {
293288
294289 #[ inline]
295290 fn validate_prefix ( buf : & [ u8 ] ) -> bool {
296- if buf. len ( ) == 0 {
291+ if buf. is_empty ( ) {
297292 return true ;
298293 }
299- match futf:: classify ( buf, buf. len ( ) - 1 ) {
294+ matches ! (
295+ futf:: classify( buf, buf. len( ) - 1 ) ,
300296 Some ( Codepoint {
301297 meaning: Meaning :: Whole ( _) ,
302298 ..
303- } ) => true ,
304- _ => false ,
305- }
299+ } )
300+ )
306301 }
307302
308303 #[ inline]
309304 fn validate_suffix ( buf : & [ u8 ] ) -> bool {
310- if buf. len ( ) == 0 {
305+ if buf. is_empty ( ) {
311306 return true ;
312307 }
313- match futf:: classify ( buf, 0 ) {
308+ matches ! (
309+ futf:: classify( buf, 0 ) ,
314310 Some ( Codepoint {
315311 meaning: Meaning :: Whole ( _) ,
316312 ..
317- } ) => true ,
318- _ => false ,
319- }
313+ } )
314+ )
320315 }
321316
322317 #[ inline]
@@ -374,10 +369,10 @@ pub struct WTF8;
374369
375370#[ inline]
376371fn wtf8_meaningful ( m : Meaning ) -> bool {
377- match m {
378- Meaning :: Whole ( _ ) | Meaning :: LeadSurrogate ( _ ) | Meaning :: TrailSurrogate ( _ ) => true ,
379- _ => false ,
380- }
372+ matches ! (
373+ m ,
374+ Meaning :: Whole ( _ ) | Meaning :: LeadSurrogate ( _ ) | Meaning :: TrailSurrogate ( _ )
375+ )
381376}
382377
383378unsafe impl Format for WTF8 {
@@ -405,7 +400,7 @@ unsafe impl Format for WTF8 {
405400
406401 #[ inline]
407402 fn validate_prefix ( buf : & [ u8 ] ) -> bool {
408- if buf. len ( ) == 0 {
403+ if buf. is_empty ( ) {
409404 return true ;
410405 }
411406 match futf:: classify ( buf, buf. len ( ) - 1 ) {
@@ -416,7 +411,7 @@ unsafe impl Format for WTF8 {
416411
417412 #[ inline]
418413 fn validate_suffix ( buf : & [ u8 ] ) -> bool {
419- if buf. len ( ) == 0 {
414+ if buf. is_empty ( ) {
420415 return true ;
421416 }
422417 match futf:: classify ( buf, 0 ) {
@@ -432,7 +427,7 @@ unsafe impl Format for WTF8 {
432427
433428 #[ inline]
434429 unsafe fn fixup ( lhs : & [ u8 ] , rhs : & [ u8 ] ) -> imp:: Fixup {
435- const ERR : & ' static str = "WTF8: internal error" ;
430+ const ERR : & str = "WTF8: internal error" ;
436431
437432 if lhs. len ( ) >= 3 && rhs. len ( ) >= 3 {
438433 if let (
0 commit comments