Skip to main content

with_interruption_handler

Function with_interruption_handler 

Source
pub fn with_interruption_handler<R>(
    handler: impl FnMut() -> bool + 'static,
    body: impl FnOnce() -> R,
) -> R
Expand description

Runs body with handler installed as the interruption handler of the calling thread, restoring the previous handler afterwards. See set_interruption_handler.

ยงExamples

use igraph::prelude::*;
use igraph::misc;

let g = Graph::from_edges(&[(0, 1), (1, 2), (2, 0)], 3, false)?;
let err = misc::with_interruption_handler(|| true, || g.sir(1.0, 1.0, 10)).unwrap_err();
assert_eq!(err.kind(), ErrorKind::Interrupted);