aboutsummaryrefslogtreecommitdiff
path: root/crates/stdx/src
diff options
context:
space:
mode:
authorBenjamin Coenen <[email protected]>2020-04-11 21:54:22 +0100
committerBenjamin Coenen <[email protected]>2020-04-11 22:45:09 +0100
commit93bfc2d05d36a47dc05a1799210327473d702dbc (patch)
treedee25e78b24b5d1b23d73ae1009bddbd060927cf /crates/stdx/src
parentd42346fed61f706d68fe888631a41ea5f2752d7f (diff)
parentfd06fe7b13045185ab4e630b0044aa9d8bbcdf8a (diff)
Improve autocompletion by looking on the type and name
Signed-off-by: Benjamin Coenen <[email protected]>
Diffstat (limited to 'crates/stdx/src')
-rw-r--r--crates/stdx/src/lib.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs
index 401a568bd..01cdf452c 100644
--- a/crates/stdx/src/lib.rs
+++ b/crates/stdx/src/lib.rs
@@ -1,6 +1,6 @@
1//! Missing batteries for standard libraries. 1//! Missing batteries for standard libraries.
2 2
3use std::{cell::Cell, fmt}; 3use std::{cell::Cell, fmt, time::Instant};
4 4
5#[inline(always)] 5#[inline(always)]
6pub fn is_ci() -> bool { 6pub fn is_ci() -> bool {
@@ -88,3 +88,17 @@ where
88 Ok(()) 88 Ok(())
89 } 89 }
90} 90}
91pub fn timeit(label: &'static str) -> impl Drop {
92 struct Guard {
93 label: &'static str,
94 start: Instant,
95 }
96
97 impl Drop for Guard {
98 fn drop(&mut self) {
99 eprintln!("{}: {:?}", self.label, self.start.elapsed())
100 }
101 }
102
103 Guard { label, start: Instant::now() }
104}