Skip to content

Commit 4f055ee

Browse files
committed
comments
Signed-off-by: Yoshua Wuyts <[email protected]>
1 parent 570dedd commit 4f055ee

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/io/write/mod.rs

+3
Original file line numberDiff line numberDiff 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())

src/io/write/write_fmt.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,16 @@ impl<T: Write + Unpin + ?Sized> Future for WriteFmtFuture<'_, T> {
2626
};
2727
}
2828

29+
// Get the types from the future.
2930
let Self { writer, amt, buffer, .. } = &mut *self;
3031
let mut buffer = buffer.as_mut().unwrap();
3132

33+
// Copy the data from the buffer into the writer until it's done.
3234
loop {
3335
if buffer.is_empty() {
3436
futures_core::ready!(Pin::new(&mut **writer).poll_flush(cx))?;
3537
return Poll::Ready(Ok(()));
3638
}
37-
3839
let i = futures_core::ready!(Pin::new(&mut **writer).poll_write(cx, &mut buffer))?;
3940
if i == 0 {
4041
return Poll::Ready(Err(io::ErrorKind::WriteZero.into()));

0 commit comments

Comments
 (0)