std-function
io::copy: stream from reader to writer
Transfer input until EOF without requiring an entire input vector. The result is the transferred byte count. The operation is not atomic and does not guarantee the destination is flushed. Expected stdout (not executed): 6 report Common mistake: Using copy on an endless input without a limit.
Formal Syntax & Structure
rust syntaxrust
io::copy(&mut reader, &mut writer) -> io::Result<u64>Working Example
Example Snippetrust
fn main() { use std::io; let mut r = &b"report"[..]; let mut out = Vec::new(); let n = io::copy(&mut r, &mut out).unwrap(); println!("{n} {}", String::from_utf8(out).unwrap());}