4
4
5
5
use crate :: cell:: { Cell , Ref , RefCell , RefMut , UnsafeCell } ;
6
6
use crate :: char:: EscapeDebugExtArgs ;
7
+ use crate :: iter;
7
8
use crate :: marker:: PhantomData ;
8
9
use crate :: mem;
9
10
use crate :: num:: fmt as numfmt;
@@ -1116,10 +1117,7 @@ pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result {
1116
1117
match args. fmt {
1117
1118
None => {
1118
1119
// 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 ) {
1123
1121
if !piece. is_empty ( ) {
1124
1122
formatter. buf . write_str ( * piece) ?;
1125
1123
}
@@ -1130,10 +1128,7 @@ pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result {
1130
1128
Some ( fmt) => {
1131
1129
// Every spec has a corresponding argument that is preceded by
1132
1130
// 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 ) {
1137
1132
if !piece. is_empty ( ) {
1138
1133
formatter. buf . write_str ( * piece) ?;
1139
1134
}
0 commit comments