mirror of
https://git.proxmox.com/git/proxmox
synced 2025-08-05 11:30:46 +00:00
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:
parent
6f125bc70b
commit
78a0a0ee1d
@ -154,14 +154,15 @@ impl ByteBuffer {
|
||||
/// free space in the buffer) and updates its size accordingly.
|
||||
///
|
||||
/// Example:
|
||||
/// ```norun
|
||||
/// // create some reader
|
||||
/// let reader = ...;
|
||||
///
|
||||
/// let mut buf = ByteBuffer::new();
|
||||
/// let res = buf.read_from(reader);
|
||||
/// // do something with the buffer
|
||||
/// ...
|
||||
/// ```
|
||||
/// # use std::io;
|
||||
/// # use proxmox::tools::byte_buffer::ByteBuffer;
|
||||
/// fn code<R: io::Read>(mut reader: R) -> io::Result<()> {
|
||||
/// let mut buf = ByteBuffer::new();
|
||||
/// let res = buf.read_from(&mut reader)?;
|
||||
/// // do something with the buffer
|
||||
/// Ok(())
|
||||
/// }
|
||||
/// ```
|
||||
pub fn read_from<T: Read + ?Sized>(&mut self, input: &mut T) -> Result<usize> {
|
||||
let amount = input.read(self.get_free_mut_slice())?;
|
||||
|
Loading…
Reference in New Issue
Block a user