proxmox/tools/byte_buffer: improve read_from example

'norun' was not a valid attribute, so cargo doc ignored it completely

instead, write a proper example that can be compiled

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Dominik Csapak 2020-07-17 14:17:10 +02:00 committed by Wolfgang Bumiller
parent 6f125bc70b
commit 78a0a0ee1d

View File

@ -154,14 +154,15 @@ impl ByteBuffer {
/// free space in the buffer) and updates its size accordingly. /// free space in the buffer) and updates its size accordingly.
/// ///
/// Example: /// Example:
/// ```norun /// ```
/// // create some reader /// # use std::io;
/// let reader = ...; /// # use proxmox::tools::byte_buffer::ByteBuffer;
/// /// fn code<R: io::Read>(mut reader: R) -> io::Result<()> {
/// let mut buf = ByteBuffer::new(); /// let mut buf = ByteBuffer::new();
/// let res = buf.read_from(reader); /// let res = buf.read_from(&mut reader)?;
/// // do something with the buffer /// // do something with the buffer
/// ... /// Ok(())
/// }
/// ``` /// ```
pub fn read_from<T: Read + ?Sized>(&mut self, input: &mut T) -> Result<usize> { pub fn read_from<T: Read + ?Sized>(&mut self, input: &mut T) -> Result<usize> {
let amount = input.read(self.get_free_mut_slice())?; let amount = input.read(self.get_free_mut_slice())?;