diff options
| author | Guillaume Gomez <guillaume.gomez@huawei.com> | 2021-07-04 15:39:45 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2021-07-04 19:23:29 +0200 |
| commit | f742cde9483dbdc3d74d6374628ffc5ba6eb424a (patch) | |
| tree | 066c49382c75b1c44937c4cb893df70d918f2b16 /library | |
| parent | 8649737beefccbef2d6bc0113df4650dd05ad7f2 (diff) | |
| download | rust-f742cde9483dbdc3d74d6374628ffc5ba6eb424a.tar.gz rust-f742cde9483dbdc3d74d6374628ffc5ba6eb424a.zip | |
Add missing code example for Write::write_vectored
Diffstat (limited to 'library')
| -rw-r--r-- | library/std/src/io/mod.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 32862629083..63233613b4b 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -1418,6 +1418,27 @@ pub trait Write { /// The default implementation calls [`write`] with either the first nonempty /// buffer provided, or an empty one if none exists. /// + /// # Examples + /// + /// ```no_run + /// use std::io::IoSlice; + /// use std::io::prelude::*; + /// use std::fs::File; + /// + /// fn main() -> std::io::Result<()> { + /// let mut data1 = [1; 8]; + /// let mut data2 = [15; 8]; + /// let io_slice1 = IoSlice::new(&mut data1); + /// let io_slice2 = IoSlice::new(&mut data2); + /// + /// let mut buffer = File::create("foo.txt")?; + /// + /// // Writes some prefix of the byte string, not necessarily all of it. + /// buffer.write_vectored(&[io_slice1, io_slice2])?; + /// Ok(()) + /// } + /// ``` + /// /// [`write`]: Write::write #[stable(feature = "iovec", since = "1.36.0")] fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize> { |
