File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -234,6 +234,9 @@ extension_trait! {
234234 where
235235 Self : Unpin ,
236236 {
237+ // In order to not have to implement an async version of `fmt` including private types
238+ // and all, we convert `Arguments` to a `Result<Vec<u8>>` and pass that to the Future.
239+ // Doing an owned conversion saves us from juggling references.
237240 let mut string = String :: new( ) ;
238241 let res = std:: fmt:: write( & mut string, fmt)
239242 . map( |_| string. into_bytes( ) )
Original file line number Diff line number Diff line change @@ -17,7 +17,6 @@ impl<T: Write + Unpin + ?Sized> Future for WriteFmtFuture<'_, T> {
1717 type Output = io:: Result < ( ) > ;
1818
1919 fn poll ( mut self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Self :: Output > {
20-
2120 // Process the interal Result the first time we run.
2221 if self . buffer . is_none ( ) {
2322 match self . res . take ( ) . unwrap ( ) {
@@ -26,15 +25,16 @@ impl<T: Write + Unpin + ?Sized> Future for WriteFmtFuture<'_, T> {
2625 } ;
2726 }
2827
28+ // Get the types from the future.
2929 let Self { writer, amt, buffer, .. } = & mut * self ;
3030 let mut buffer = buffer. as_mut ( ) . unwrap ( ) ;
3131
32+ // Copy the data from the buffer into the writer until it's done.
3233 loop {
3334 if buffer. is_empty ( ) {
3435 futures_core:: ready!( Pin :: new( & mut * * writer) . poll_flush( cx) ) ?;
3536 return Poll :: Ready ( Ok ( ( ) ) ) ;
3637 }
37-
3838 let i = futures_core:: ready!( Pin :: new( & mut * * writer) . poll_write( cx, & mut buffer) ) ?;
3939 if i == 0 {
4040 return Poll :: Ready ( Err ( io:: ErrorKind :: WriteZero . into ( ) ) ) ;
You can’t perform that action at this time.
0 commit comments