File tree Expand file tree Collapse file tree 1 file changed +3
-12
lines changed Expand file tree Collapse file tree 1 file changed +3
-12
lines changed Original file line number Diff line number Diff line change @@ -14,18 +14,8 @@ pub fn is_ci() -> bool {
14
14
15
15
#[ must_use]
16
16
pub fn timeit ( label : & ' static str ) -> impl Drop {
17
- struct Guard {
18
- label : & ' static str ,
19
- start : Instant ,
20
- }
21
-
22
- impl Drop for Guard {
23
- fn drop ( & mut self ) {
24
- eprintln ! ( "{}: {:.2?}" , self . label, self . start. elapsed( ) )
25
- }
26
- }
27
-
28
- Guard { label, start : Instant :: now ( ) }
17
+ let start = Instant :: now ( ) ;
18
+ defer ( move || eprintln ! ( "{}: {:.2?}" , label, start. elapsed( ) ) )
29
19
}
30
20
31
21
/// Prints backtrace to stderr, useful for debugging.
@@ -179,6 +169,7 @@ where
179
169
start..start + len
180
170
}
181
171
172
+ #[ must_use]
182
173
pub fn defer < F : FnOnce ( ) > ( f : F ) -> impl Drop {
183
174
struct D < F : FnOnce ( ) > ( Option < F > ) ;
184
175
impl < F : FnOnce ( ) > Drop for D < F > {
You can’t perform that action at this time.
0 commit comments