Skip to main content

set_cycle_handler

Function set_cycle_handler 

Source
pub fn set_cycle_handler<T>(handler: T)
where T: FnMut(&str) + Send + Sync + 'static,
Available on crate feature experimental only.
Expand description

Install a new cycle handler

This function will be called whenever a cycle in the dependency graph is detected. The default handler will panic with a message describing the panic, but this can be downgraded to logging, or even some complicated reporting mechanism.

let mut logged = false;

set_cycle_handler(move |message| {
    if !logged {
        logged = true;
        eprintln!("{message}");
    }
});

This handler can be reset to its original state via reset_cycle_handler.