summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/unused_io_amount.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/src/docs/unused_io_amount.txt')
-rw-r--r--src/tools/clippy/src/docs/unused_io_amount.txt31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/unused_io_amount.txt b/src/tools/clippy/src/docs/unused_io_amount.txt
new file mode 100644
index 000000000..fbc4c299c
--- /dev/null
+++ b/src/tools/clippy/src/docs/unused_io_amount.txt
@@ -0,0 +1,31 @@
+### What it does
+Checks for unused written/read amount.
+
+### Why is this bad?
+`io::Write::write(_vectored)` and
+`io::Read::read(_vectored)` are not guaranteed to
+process the entire buffer. They return how many bytes were processed, which
+might be smaller
+than a given buffer's length. If you don't need to deal with
+partial-write/read, use
+`write_all`/`read_exact` instead.
+
+When working with asynchronous code (either with the `futures`
+crate or with `tokio`), a similar issue exists for
+`AsyncWriteExt::write()` and `AsyncReadExt::read()` : these
+functions are also not guaranteed to process the entire
+buffer. Your code should either handle partial-writes/reads, or
+call the `write_all`/`read_exact` methods on those traits instead.
+
+### Known problems
+Detects only common patterns.
+
+### Examples
+```
+use std::io;
+fn foo<W: io::Write>(w: &mut W) -> io::Result<()> {
+ // must be `w.write_all(b"foo")?;`
+ w.write(b"foo")?;
+ Ok(())
+}
+``` \ No newline at end of file