[solved] Confusion on Read::read docs


#1

In the docs for the read method from the [Read][1] trait is the following paragraph:

fn read(&mut self, buf: &mut [u8]) -> Result


> No guarantees are provided about the contents of `buf` when this function is called, implementations cannot rely on any property of the contents of `buf` being true. It is recommended that implementations only write data to buf instead of reading its contents.

This confuses me greatly.  After reading data into a buffer, what else can I do with it, if I can't read it?  


  [1]: https://doc.rust-lang.org/nightly/std/io/trait.Read.html#tymethod.read

#2

The key word is “implementations”. This warning applies to all implementers of the Read trait, not consumers of the API:

impl Read for Something {
    fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
        // Do not read buf, only write to it.
    }
}

#3

That makes perfect sense, thanks!