44
55use crate :: cell:: { Cell , Ref , RefCell , RefMut , UnsafeCell } ;
66use crate :: char:: EscapeDebugExtArgs ;
7+ use crate :: iter;
78use crate :: marker:: PhantomData ;
89use crate :: mem;
910use crate :: num:: fmt as numfmt;
@@ -1116,10 +1117,7 @@ pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result {
11161117 match args. fmt {
11171118 None => {
11181119 // We can use default formatting parameters for all arguments.
1119- for ( i, arg) in args. args . iter ( ) . enumerate ( ) {
1120- // SAFETY: args.args and args.pieces come from the same Arguments,
1121- // which guarantees the indexes are always within bounds.
1122- let piece = unsafe { args. pieces . get_unchecked ( i) } ;
1120+ for ( arg, piece) in iter:: zip ( args. args , args. pieces ) {
11231121 if !piece. is_empty ( ) {
11241122 formatter. buf . write_str ( * piece) ?;
11251123 }
@@ -1130,10 +1128,7 @@ pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result {
11301128 Some ( fmt) => {
11311129 // Every spec has a corresponding argument that is preceded by
11321130 // a string piece.
1133- for ( i, arg) in fmt. iter ( ) . enumerate ( ) {
1134- // SAFETY: fmt and args.pieces come from the same Arguments,
1135- // which guarantees the indexes are always within bounds.
1136- let piece = unsafe { args. pieces . get_unchecked ( i) } ;
1131+ for ( arg, piece) in iter:: zip ( fmt, args. pieces ) {
11371132 if !piece. is_empty ( ) {
11381133 formatter. buf . write_str ( * piece) ?;
11391134 }
0 commit comments