8671: minor: simplify r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2021-04-26 16:31:19 +00:00 committed by GitHub
commit c5364ffde1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,18 +14,8 @@ pub fn is_ci() -> bool {
#[must_use]
pub fn timeit(label: &'static str) -> impl Drop {
struct Guard {
label: &'static str,
start: Instant,
}
impl Drop for Guard {
fn drop(&mut self) {
eprintln!("{}: {:.2?}", self.label, self.start.elapsed())
}
}
Guard { label, start: Instant::now() }
let start = Instant::now();
defer(move || eprintln!("{}: {:.2?}", label, start.elapsed()))
}
/// Prints backtrace to stderr, useful for debugging.
@ -179,6 +169,7 @@ pub fn equal_range_by<T, F>(slice: &[T], mut key: F) -> ops::Range<usize>
start..start + len
}
#[must_use]
pub fn defer<F: FnOnce()>(f: F) -> impl Drop {
struct D<F: FnOnce()>(Option<F>);
impl<F: FnOnce()> Drop for D<F> {