diff options
| author | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2016-10-22 12:50:00 +0200 |
|---|---|---|
| committer | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2016-10-27 15:25:14 +0200 |
| commit | 9568f448422384b42fc84080e996a6914211f6a0 (patch) | |
| tree | 8aa6f6b8809657424cdef4692360d7e8de26cea8 | |
| parent | 7bccb829d0fe9a733bd6efcf6f7313186ae237ab (diff) | |
| download | rust-9568f448422384b42fc84080e996a6914211f6a0.tar.gz rust-9568f448422384b42fc84080e996a6914211f6a0.zip | |
Add documentation for Read, Write impls for slices and Vec
The Write impls for &[u8] and Vec<u8> are quite different, and we need this to be reflected in the docs. These documentation comments will be visible on the respective type's page in the trait impls section.
| -rw-r--r-- | src/libstd/io/impls.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libstd/io/impls.rs b/src/libstd/io/impls.rs index cd05e6b5de9..6b26c016638 100644 --- a/src/libstd/io/impls.rs +++ b/src/libstd/io/impls.rs @@ -147,6 +147,10 @@ impl<B: BufRead + ?Sized> BufRead for Box<B> { // ============================================================================= // In-memory buffer implementations +/// Read is implemented for `&[u8]` by copying from the slice. +/// +/// Note that reading updates the slice to point to the yet unread part. +/// The slice will be empty when EOF is reached. #[stable(feature = "rust1", since = "1.0.0")] impl<'a> Read for &'a [u8] { #[inline] @@ -180,6 +184,11 @@ impl<'a> BufRead for &'a [u8] { fn consume(&mut self, amt: usize) { *self = &self[amt..]; } } +/// Write is implemented for `&mut [u8]` by copying into the slice, overwriting +/// its data. +/// +/// Note that writing updates the slice to point to the yet unwritten part. +/// The slice will be empty when it has been completely overwritten. #[stable(feature = "rust1", since = "1.0.0")] impl<'a> Write for &'a mut [u8] { #[inline] @@ -204,6 +213,8 @@ impl<'a> Write for &'a mut [u8] { fn flush(&mut self) -> io::Result<()> { Ok(()) } } +/// Write is implemented for `Vec<u8>` by appending to the vector. +/// The vector will grow as needed. #[stable(feature = "rust1", since = "1.0.0")] impl Write for Vec<u8> { #[inline] |
