Unverified Commit 56cf68a8 authored by Javier Cano's avatar Javier Cano Committed by GitHub
Browse files

Add flush to ByteStream code example in docs (#1005)

In the examples on how to copy a ByterStream to a file flush
is not called explicitly. A user copying this code may hit
some race condition as the flush will happen asynchronously.
This deviates from the std file implementation that flushes on drop
and may be confusing if not explicitly stated in the example.
parent 6326a069
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
//!     let mut buf = output.audio_stream.collect().await?;
//!     let mut file = File::open("audio.mp3").await?;
//!     file.write_all_buf(&mut buf).await?;
//!     file.flush().await?;
//!     Ok(())
//! }
//! ```
@@ -68,6 +69,7 @@
//!         let bytes: Bytes = bytes?;
//!         file.write_all(&bytes).await?;
//!     }
//!     file.flush().await?;
//!     Ok(())
//! }
//! ```