[pbs-devel] [PATCH proxmox v2 4/4] proxmox/tools/byte_buffer: improve read_from example

Dominik Csapak d.csapak at proxmox.com
Fri Jul 17 14:17:10 CEST 2020


'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 at proxmox.com>
---
 proxmox/src/tools/byte_buffer.rs | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/proxmox/src/tools/byte_buffer.rs b/proxmox/src/tools/byte_buffer.rs
index f01a6dd..24aec11 100644
--- a/proxmox/src/tools/byte_buffer.rs
+++ b/proxmox/src/tools/byte_buffer.rs
@@ -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())?;
-- 
2.20.1






More information about the pbs-devel mailing list