diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index ab9aa29..f6f447b 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -8,6 +8,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: toolchain: stable + - run: cargo check --package ulid-cli - run: cargo test - run: cargo test --all-features - run: cargo test --no-default-features --features=std diff --git a/benches/bench.rs b/benches/bench.rs index 0a62802..ed0a091 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -3,7 +3,7 @@ use std::time::SystemTime; use ulid::{Generator, Ulid, ULID_LEN}; fn bench_new(b: &mut Bencher) { - b.iter(|| Ulid::new()); + b.iter(Ulid::new); } fn bench_generator_generate(b: &mut Bencher) { diff --git a/cli/Cargo.toml b/cli/Cargo.toml index e000f95..6b730ec 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -16,3 +16,4 @@ edition = "2018" [dependencies] structopt = "0.2" ulid = { version = "*", path = ".." } +time = "0.3.11" diff --git a/cli/src/bin/ulid.rs b/cli/src/bin/ulid.rs index fd41be0..c63f641 100644 --- a/cli/src/bin/ulid.rs +++ b/cli/src/bin/ulid.rs @@ -62,7 +62,7 @@ fn generate(count: u32, monotonic: bool) { fn inspect(values: &[String]) { for val in values { - let ulid = Ulid::from_string(&val); + let ulid = Ulid::from_string(val); match ulid { Ok(ulid) => { let upper_hex = format!("{:X}", ulid.0); @@ -81,7 +81,7 @@ COMPONENTS: ", ulid.to_string(), upper_hex, - ulid.datetime(), + time::OffsetDateTime::from(ulid.datetime()), ulid.timestamp_ms(), upper_hex.chars().skip(6).collect::() ); diff --git a/src/generator.rs b/src/generator.rs index 62fdb30..b374762 100644 --- a/src/generator.rs +++ b/src/generator.rs @@ -172,6 +172,7 @@ impl fmt::Display for MonotonicError { #[cfg(test)] mod tests { use super::*; + use std::time::Duration; #[test] fn test_order_monotonic() {