Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document methods a little better? #17

Open
polarathene opened this issue Jan 2, 2021 · 0 comments
Open

Document methods a little better? #17

polarathene opened this issue Jan 2, 2021 · 0 comments

Comments

@polarathene
Copy link

  • start_new() is presumably a convenience method for doing new() + start() in one call?
  • Difference between reset() and restart()?

Just from a glance of the the minimal info presented to a user, those were two things that stood out. Compared to using the standard Instant from Rust, I was interested in time taken between calls, turned out that was added as a feature that never arrived to crates.io.

As a user, I can try the methods out individually, but knowing in advance would have been nicer. Below is for any other user not wanting to try the API out or look over source:

  • restart(): Continues running the timer but restarting from 0.
  • reset(): Stops the timer and resets the value to 0.
  • stop(): Stops the timer but doesn't reset the value.
  • new(): Creates a timer but does not start it. restart() will also initiate the timer like start(). Must be mutable to track time.
  • start_new(): Creates the timer and starts it. Does not need to be mutable for elapsed time tracking.

For lap functionality where you want to get the elapsed time since your previous measurement, you need a mutable stopwatch and to call sw.restart() between your two sw.elapsed_ms() calls. Alternatively if you source the crate from github instead of crates.io, you can use sw.elapsed_split_ms()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant