From 7e70d7183f890ba275ab9ef9566f3a7710507973 Mon Sep 17 00:00:00 2001 From: holly sparkles Date: Sun, 14 Jan 2024 19:30:55 +0100 Subject: [PATCH] chore(docs): update readme --- README.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c42d58f..e6ec9eb 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,33 @@ A small stopwatch library written in Rust. +## Usage + +```rust +use std::time::Duration; +use stopwatch::Stopwatch; + +let mut stopwatch = Stopwatch::new(); + +stopwatch.start(); + +// Do a long running task +std::thread::sleep(Duration::from_secs(5)); + +stopwatch.stop(); + +println!("Operation complete in: {}", stopwatch); +``` + +## Installation + +```shell +cargo add --git https://git.holly.sh/stopwatch.git +``` + ## Why does this exist? -While there is the [rust-stopwatch](https://crates.io/crates/stopwatch) crate, I didn't like that a simple stopwatch crate had a dependency on [num](https://crates.io/crates/num). +While there is the [rust-stopwatch](https://crates.io/crates/stopwatch) crate, I didn't like that a simple stopwatch crate had a dependency on [num](https://crates.io/crates/num), which has other dependencies. This is done in pure Rust. -- libgit2 1.7.2