pub fn is_interrupt(err: &Error) -> boolExpand description
Wether the error in question originated from an Interruptor
calling Interruptor::interrupt.
This just checks if the error is of type InterruptReceived.
ยงExamples
use std::io::{BufRead, Read, Result};
use interrupt_read::{InterruptReader, is_interrupt};
// Read until either `Ok(0)` or an interrupt occurred.
fn interrupt_read_loop(mut reader: InterruptReader<impl Read>) -> Result<String> {
let mut string = String::new();
loop {
match reader.read_line(&mut string) {
Ok(0) => break Ok(string),
Ok(_) => {}
Err(err) if is_interrupt(&err) => break Ok(string),
Err(err) => break Err(err),
}
}
}