How to return an error in your example?
pub fn read(path: Path) -> Result<Bytes> {
File::open(path)?.read_to_end()
}
isn't so bad either.It compromises a bit on generality and (potential) performance to achieve better readability and succinctness. Often a worthwhile trade-off, but not something the standard library can always do.
proving the point of the article even further
use std::io;
pub fn read(path: Path) -> io::Result<Bytes> {
File::open(path)?.read_to_end()
}