std-method

Read::bytes: byte iterator

Iterate over individual byte results. Each item may carry an error; collecting into io::Result<Vec<_>> preserves the first error. For expensive input sources prefer buffering. Expected stdout (not executed): [65, 66] Common mistake: Ignoring errors with a filter that silently drops failed reads.

Formal Syntax & Structure

rust syntaxrust
reader.bytes() -> Bytes<Self>

Working Example

Example Snippetrust
fn main() {    use std::io::{self, Read};    let bytes: io::Result<Vec<u8>> = (&b"AB"[..]).bytes().collect();    println!("{:?}", bytes.unwrap());}
Rust Reference