Guest User

Untitled

a guest
Apr 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. use std::time::Instant;
  2.  
  3. struct Profile {
  4. lbl: &'static str,
  5. start: Instant,
  6. }
  7. impl Profile {
  8. pub fn new(lbl: &'static str) -> Self {
  9. Profile {
  10. lbl,
  11. start: Instant::now(),
  12. }
  13. }
  14. }
  15.  
  16. impl Drop for Profile {
  17. fn drop(&mut self) {
  18. println!("{} {:?}", self.lbl, self.start.elapsed());
  19. }
  20. }
  21.  
  22. fn main() {
  23. {
  24. let _prof = Profile::new("foo");
  25. println!("work work work");
  26. }
  27. }
Add Comment
Please, Sign In to add comment