abi_stable_derive/
utils.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use std::{panic::Location, time::Instant};

pub(crate) use as_derive_utils::utils::{
    dummy_ident,
    expr_from_ident,
    expr_from_int,
    join_spans,
    type_from_ident,
    //take_manuallydrop,
    uint_lit,
    LinearResult,
    SynResultExt,
};

#[allow(dead_code)]
pub struct PrintDurationOnDrop {
    start: Instant,
    file_span: &'static Location<'static>,
}

impl PrintDurationOnDrop {
    #[allow(dead_code)]
    pub fn new() -> Self {
        Self {
            start: Instant::now(),
            file_span: Location::caller(),
        }
    }
}

impl Drop for PrintDurationOnDrop {
    fn drop(&mut self) {
        let span = self.file_span;
        let dur = self.start.elapsed();
        println!("{}-{}:taken {:?} to run", span.file(), span.line(), dur);
    }
}