Hi,

It could probably be improved by having a Reader::operate method which wraps some code in a closure and will return a result that is a failure if any of the wrapped IO operations failed:

    use std::io::BufferedReader;
    use std::io::File;

    let path = Path::new("message.txt");
    let mut file = BufferedReader::new(File::open(&path));
    let nil_result = file.operate(|| {
        for line in file.lines() {
            print!("{}", line);
        }
        Ok(())
    }).unwrap();

Regards,
Armin
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to