Skip to content

Commit

Permalink
Merge pull request #9 from museun/caveat
Browse files Browse the repository at this point in the history
Mention `sync` enables a global singleton across all threads
  • Loading branch information
museun authored Feb 16, 2024
2 parents ba412a8 + 3fc0601 commit cd6dd3d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mock_instant"
version = "0.3.0"
version = "0.3.1"
authors = ["museun <museun@outlook.com>"]
edition = "2018"
license = "0BSD"
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,10 @@ MockClock::advance_system_time(Duration::from_secs(2));
assert_eq!(now.elapsed().unwrap(), Duration::from_secs(17));
```

# Caveats

If the `sync` feature is enabled then all tests using this crate will use a global singleton clock.

see <https://github.com/museun/mock_instant/issues/6>

License: 0BSD
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ mock_instant = { version = "0.2", features = ["sync"] }
It provides a replacement `std::time::Instant` and `std::time::SystemTime` that uses a deterministic thread-local 'clock'
**NOTE:** if this is enabled then all tests will use the same singleton `MockClock` source
---
You can swap out the `std::time::Instant` with this one by doing something similar to:
```rust
#[cfg(test)]
Expand Down

0 comments on commit cd6dd3d

Please sign in to comment.