@@ -787,12 +787,12 @@ impl String {
787787#[ cfg( not( no_global_oom_handling) ) ]  
788788    #[ unstable( feature = "str_from_utf16_endian" ,  issue = "116258" ) ]  
789789    pub  fn  from_utf16le ( v :  & [ u8 ] )  -> Result < String ,  FromUtf16Error >  { 
790-         if  v . len ( )  %  2  !=  0  { 
790+         let   ( chunks ,   [ ] )  = v . as_chunks :: < 2 > ( )   else  { 
791791            return  Err ( FromUtf16Error ( ( ) ) ) ; 
792-         } 
792+         } ; 
793793        match  ( cfg ! ( target_endian = "little" ) ,  unsafe  {  v. align_to :: < u16 > ( )  } )  { 
794794            ( true ,  ( [ ] ,  v,  [ ] ) )  => Self :: from_utf16 ( v) , 
795-             _ => char:: decode_utf16 ( v . array_chunks :: < 2 > ( ) . copied ( ) . map ( u16:: from_le_bytes) ) 
795+             _ => char:: decode_utf16 ( chunks . iter ( ) . copied ( ) . map ( u16:: from_le_bytes) ) 
796796                . collect :: < Result < _ ,  _ > > ( ) 
797797                . map_err ( |_| FromUtf16Error ( ( ) ) ) , 
798798        } 
@@ -830,11 +830,11 @@ impl String {
830830            ( true ,  ( [ ] ,  v,  [ ] ) )  => Self :: from_utf16_lossy ( v) , 
831831            ( true ,  ( [ ] ,  v,  [ _remainder] ) )  => Self :: from_utf16_lossy ( v)  + "\u{FFFD} " , 
832832            _ => { 
833-                 let  mut  iter  = v. array_chunks :: < 2 > ( ) ; 
834-                 let  string = char:: decode_utf16 ( iter . by_ref ( ) . copied ( ) . map ( u16:: from_le_bytes) ) 
833+                 let  ( chunks ,  remainder )  = v. as_chunks :: < 2 > ( ) ; 
834+                 let  string = char:: decode_utf16 ( chunks . iter ( ) . copied ( ) . map ( u16:: from_le_bytes) ) 
835835                    . map ( |r| r. unwrap_or ( char:: REPLACEMENT_CHARACTER ) ) 
836836                    . collect ( ) ; 
837-                 if  iter . remainder ( ) . is_empty ( )  {  string }  else  {  string + "\u{FFFD} "  } 
837+                 if  remainder. is_empty ( )  {  string }  else  {  string + "\u{FFFD} "  } 
838838            } 
839839        } 
840840    } 
@@ -862,12 +862,12 @@ impl String {
862862#[ cfg( not( no_global_oom_handling) ) ]  
863863    #[ unstable( feature = "str_from_utf16_endian" ,  issue = "116258" ) ]  
864864    pub  fn  from_utf16be ( v :  & [ u8 ] )  -> Result < String ,  FromUtf16Error >  { 
865-         if  v . len ( )  %  2  !=  0  { 
865+         let   ( chunks ,   [ ] )  = v . as_chunks :: < 2 > ( )   else  { 
866866            return  Err ( FromUtf16Error ( ( ) ) ) ; 
867-         } 
867+         } ; 
868868        match  ( cfg ! ( target_endian = "big" ) ,  unsafe  {  v. align_to :: < u16 > ( )  } )  { 
869869            ( true ,  ( [ ] ,  v,  [ ] ) )  => Self :: from_utf16 ( v) , 
870-             _ => char:: decode_utf16 ( v . array_chunks :: < 2 > ( ) . copied ( ) . map ( u16:: from_be_bytes) ) 
870+             _ => char:: decode_utf16 ( chunks . iter ( ) . copied ( ) . map ( u16:: from_be_bytes) ) 
871871                . collect :: < Result < _ ,  _ > > ( ) 
872872                . map_err ( |_| FromUtf16Error ( ( ) ) ) , 
873873        } 
@@ -905,11 +905,11 @@ impl String {
905905            ( true ,  ( [ ] ,  v,  [ ] ) )  => Self :: from_utf16_lossy ( v) , 
906906            ( true ,  ( [ ] ,  v,  [ _remainder] ) )  => Self :: from_utf16_lossy ( v)  + "\u{FFFD} " , 
907907            _ => { 
908-                 let  mut  iter  = v. array_chunks :: < 2 > ( ) ; 
909-                 let  string = char:: decode_utf16 ( iter . by_ref ( ) . copied ( ) . map ( u16:: from_be_bytes) ) 
908+                 let  ( chunks ,  remainder )  = v. as_chunks :: < 2 > ( ) ; 
909+                 let  string = char:: decode_utf16 ( chunks . iter ( ) . copied ( ) . map ( u16:: from_be_bytes) ) 
910910                    . map ( |r| r. unwrap_or ( char:: REPLACEMENT_CHARACTER ) ) 
911911                    . collect ( ) ; 
912-                 if  iter . remainder ( ) . is_empty ( )  {  string }  else  {  string + "\u{FFFD} "  } 
912+                 if  remainder. is_empty ( )  {  string }  else  {  string + "\u{FFFD} "  } 
913913            } 
914914        } 
915915    } 
@@ -2611,7 +2611,7 @@ impl_eq! { Cow<'a, str>, &'b str }
26112611impl_eq !  {  Cow <' a,  str >,  String  } 
26122612
26132613#[ stable( feature = "rust1" ,  since = "1.0.0" ) ]  
2614- #[ rustc_const_unstable( feature = "const_default" ,  issue = "67792 " ) ]  
2614+ #[ rustc_const_unstable( feature = "const_default" ,  issue = "143894 " ) ]  
26152615impl  const  Default  for  String  { 
26162616    /// Creates an empty `String`. 
26172617#[ inline]  
0 commit comments