Skip to content

Commit d7f15ad

Browse files
authored
chore: update deps and docs (#4)
Signed-off-by: tison <[email protected]>
1 parent 910e54d commit d7f15ad

File tree

6 files changed

+35
-41
lines changed

6 files changed

+35
-41
lines changed

.github/workflows/ci.yml

+21-8
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,30 @@ env:
1010
CARGO_TERM_COLOR: always
1111

1212
jobs:
13+
check:
14+
runs-on: ubuntu-24.04
15+
env:
16+
RUST_BACKTRACE: 1
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: Swatinem/rust-cache@v2
20+
- name: Set up toolchains
21+
uses: dtolnay/rust-toolchain@master
22+
with:
23+
toolchain: nightly
24+
components: rustfmt, clippy
25+
- name: Check format
26+
run: cargo +nightly fmt --all -- --check
27+
- name: Clippy
28+
run: cargo +nightly clippy --workspace --all-targets --all-features -- -D warnings
29+
1330
build:
1431
runs-on: ${{ matrix.os }}
1532
strategy:
1633
fail-fast: false
1734
matrix:
18-
os: [ macos-latest, ubuntu-latest, windows-latest ]
35+
os: [ ubuntu-24.04, macos-14, windows-2022 ]
1936
features: [ "atomic", "atomic,fallback-coarse" ]
20-
rust: [ stable ]
2137
env:
2238
RUST_BACKTRACE: 1
2339
steps:
@@ -26,23 +42,20 @@ jobs:
2642
- name: Set up toolchains
2743
uses: dtolnay/rust-toolchain@master
2844
with:
29-
toolchain: ${{ matrix.rust }}
45+
toolchain: stable
3046
components: rustfmt, clippy
31-
- name: Check format
32-
run: cargo fmt --all -- --check
3347
- name: Build
3448
run: cargo build --workspace --all-targets --features ${{ matrix.features }}
35-
- name: Clippy
36-
run: cargo clippy --workspace --all-targets --features ${{ matrix.features }} -- -D warnings
3749
- name: Run tests
3850
run: cargo test --workspace --all-targets --features ${{ matrix.features }} -- --nocapture
3951
- name: Run benches
4052
run: cargo bench --workspace --all-targets --features ${{ matrix.features }}
4153

4254
build-wasm:
43-
runs-on: ubuntu-latest
55+
runs-on: ubuntu-24.04
4456
env:
4557
RUST_BACKTRACE: 1
58+
RUSTFLAGS: --cfg getrandom_backend="wasm_js"
4659
steps:
4760
- uses: actions/checkout@v4
4861
- name: Set up toolchains

Cargo.toml

+10-8
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,25 @@ all-features = true
1515
rustdoc-args = ["--cfg", "docsrs"]
1616

1717
[dependencies]
18-
ctor = "0.2"
1918
coarsetime = { version = "0.1", optional = true }
20-
web-time = "1.0"
19+
small_ctor = { version = "0.1.2" }
20+
web-time = { version = "1.1.0" }
2121

2222
[features]
2323
atomic = []
2424
fallback-coarse = ["coarsetime"]
2525

2626
[dev-dependencies]
2727
criterion = { version = "0.5", default-features = false, features = [
28-
"plotters",
29-
"cargo_bench_support",
28+
"plotters",
29+
"cargo_bench_support",
3030
] }
31-
quanta = "0.12"
32-
rand = "0.8"
33-
wasm-bindgen-test = "0.3"
34-
getrandom = { version = "0.2", features = ["js"] }
31+
quanta = { version = "0.12.5" }
32+
rand = { version = "0.9.0" }
33+
wasm-bindgen-test = { version = "0.3.50" }
34+
35+
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
36+
getrandom = { version = "0.3", features = ["wasm_js"] }
3537

3638
[[bench]]
3739
name = "criterion"

rustfmt.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ normalize_comments = true
77
overflow_delimited_expr = true
88
reorder_imports = true
99
trailing_comma = "Vertical"
10-
version = "Two"
10+
style_edition = "2021"
1111
where_single_line = true
1212
wrap_comments = true

src/instant.rs

-21
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ impl Instant {
3636
/// Returns the amount of time elapsed from another instant to this one,
3737
/// or zero duration if that instant is later than this one.
3838
///
39-
/// # Panics
40-
///
41-
/// Previously we panicked if `earlier` was later than `self`. Currently, this method saturates
42-
/// to follow the behavior of the standard library. Future versions may reintroduce the panic
43-
/// in some circumstances.
44-
///
4539
/// # Examples
4640
///
4741
/// ```
@@ -109,12 +103,6 @@ impl Instant {
109103

110104
/// Returns the amount of time elapsed since this instant was created.
111105
///
112-
/// # Panics
113-
///
114-
/// This function may panic if the current time is earlier than this
115-
/// instant, which is something that can happen if an `Instant` is
116-
/// produced synthetically.
117-
///
118106
/// # Examples
119107
///
120108
/// ```
@@ -218,12 +206,6 @@ impl Sub<Instant> for Instant {
218206

219207
/// Returns the amount of time elapsed from another instant to this one,
220208
/// or zero duration if that instant is later than this one.
221-
///
222-
/// # Panics
223-
///
224-
/// Previously we panicked if `other` was later than `self`. Currently, this method saturates
225-
/// to follow the behavior of the standard library. Future versions may reintroduce the panic
226-
/// in some circumstances.
227209
fn sub(self, other: Instant) -> Duration {
228210
self.duration_since(other)
229211
}
@@ -270,9 +252,6 @@ mod atomic {
270252
use std::sync::atomic::AtomicU64;
271253
use std::sync::atomic::Ordering;
272254

273-
#[cfg(doc)]
274-
use Ordering::*;
275-
276255
use super::Instant;
277256

278257
/// Atomic variant of [`Instant`].

src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ mod tests {
143143

144144
#[test]
145145
fn test_duration() {
146-
let mut rng = rand::thread_rng();
146+
let mut rng = rand::rng();
147147
for _ in 0..10 {
148148
let instant = Instant::now();
149149
let std_instant = StdInstant::now();
150-
std::thread::sleep(Duration::from_millis(rng.gen_range(100..500)));
150+
std::thread::sleep(Duration::from_millis(rng.random_range(100..500)));
151151
let check = move || {
152152
let duration_ns_fastant = instant.elapsed();
153153
let duration_ns_std = std_instant.elapsed();

src/tsc_now.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct TSCState {
2121

2222
unsafe impl Sync for TSCState {}
2323

24-
#[ctor::ctor]
24+
#[small_ctor::ctor]
2525
unsafe fn init() {
2626
let tsc_level = TSCLevel::get();
2727
let is_tsc_available = match &tsc_level {

0 commit comments

Comments
 (0)