Skip to content

JayKickliter/dropclock

Repository files navigation

dropclock

CI docs.rs main docs

This crate provides DropClock, a guard type that captures std::time::Instant::now() on creation and, when dropped, passes that instant to a user-provided closure. Useful for timing scopes, logging elapsed durations, or recording metrics without manual bookkeeping.

use dropclock::DropClock;

let _timer = DropClock::new(|start| {
    eprintln!("elapsed: {:?}", start.elapsed());
});
// ... your code here ...
// closure fires when _timer is dropped

License

Licensed under either of Apache License, Version 2.0 or MIT License at your option.

About

A guard type that captures Instant::now() on creation and passes it to a closure on drop.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

 
 
 

Contributors