abi_stable_derive/
utils.rs

1use std::{panic::Location, time::Instant};
2
3pub(crate) use as_derive_utils::utils::{
4    dummy_ident,
5    expr_from_ident,
6    expr_from_int,
7    join_spans,
8    type_from_ident,
9    //take_manuallydrop,
10    uint_lit,
11    LinearResult,
12    SynResultExt,
13};
14
15#[allow(dead_code)]
16pub struct PrintDurationOnDrop {
17    start: Instant,
18    file_span: &'static Location<'static>,
19}
20
21impl PrintDurationOnDrop {
22    #[allow(dead_code)]
23    pub fn new() -> Self {
24        Self {
25            start: Instant::now(),
26            file_span: Location::caller(),
27        }
28    }
29}
30
31impl Drop for PrintDurationOnDrop {
32    fn drop(&mut self) {
33        let span = self.file_span;
34        let dur = self.start.elapsed();
35        println!("{}-{}:taken {:?} to run", span.file(), span.line(), dur);
36    }
37}