iroh_test/lib.rs
1//! Internal utilities to support testing.
2
3pub mod hexdump;
4pub mod logging;
5
6// #[derive(derive_more::Debug)]
7#[allow(missing_debug_implementations)]
8pub struct CallOnDrop(Option<Box<dyn FnOnce()>>);
9
10impl CallOnDrop {
11 pub fn new(f: impl FnOnce() + 'static) -> Self {
12 Self(Some(Box::new(f)))
13 }
14}
15
16impl Drop for CallOnDrop {
17 fn drop(&mut self) {
18 if let Some(f) = self.0.take() {
19 f();
20 }
21 }
22}