Because being symmetric is not the only goal of API design. Specifically for Rust, performance is another important goal, current API does not allocate, while your interface needs an allocation like Result<Vec<u8>> (Result<[u8]> does not work).
(burntsushi is trying to get you to think carefully about the feasibility of your proposal. if you’re still a bit uncertain, have another look at https://doc.rust-lang.org/book/unsized-types.html )
Unless this was an equivalent of read_to_end, I now see that the API would have to accept another argument, one that specifies “how much to read at most”.
then you’d be forcing an allocation on the caller, which has significant implications for performance. For example, if I don’t need to hold the entire contents of my underlying reader in memory at once, then I can allocate a single buffer and process the input incrementally:
let mut buf = vec![0; 1024]; // process 1024 bytes at a time
loop {
buf.clear();
let n = try!(reader.read(&mut buf));
if n == 0 { // EOF
break;
}
let block = &buf[0..n];
// do something with the bytes in `block` ...
}
If read always returned a Vec, then I wouldn’t be able to amortize the allocation of buf like in the above code. Instead, I’d be forced to create a new one for every call to read.