dropclock 0.1.0

A guard type that runs a closure with the creation instant on drop
Documentation
  • Coverage
  • 100%
    4 out of 4 items documented1 out of 4 items with examples
  • Size
  • Source code size: 19.24 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.28 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • JayKickliter/dropclock
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • JayKickliter

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.