O'Reilly logo
  • Ivan Zderadicka thinks this is interesting:

let mut reader = BufReader::new(&stream);

// Read server's public key
reader.read_until(b'\n', &mut buffer)

From

Cover of Network Programming with Rust

Note

This is clearly wrong - sever public key is send as stream of arbitrary bytes. What if it will contain b'\n' - for this example read_to_end should be enough and then we do not need buffered reader.