Ideas Want to Be Shared
kk.org57 pointsby exrook18 comments
fn process_file(p: Path) -> Result<String, io::Error> {
let file = File::open(p)?; //Return err if file can't be opened
let mut out = String::new();
file.read_to_string(&mut out)?; // Return err if read fails
out
}
If you want to handle the error case within the same function `try` blocks are available in nightly[0] and will eventually come to stable[1]
See the original post and discussion for the whole story:
https://nee.lv/2021/02/28/How-I-cut-GTA-Online-loading-times... https://news.ycombinator.com/item?id=26296339