Skip to content

Commit

Permalink
Merge pull request #37 from communityvi/update-dependencies
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
FSMaxB committed Nov 10, 2023
2 parents f1fa145 + 16e058b commit 428bb9b
Show file tree
Hide file tree
Showing 9 changed files with 378 additions and 231 deletions.
568 changes: 365 additions & 203 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[workspace]
members = ["async-time-mock*"]
resolver = "2"
8 changes: 1 addition & 7 deletions async-time-mock-async-std/src/instant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,7 @@ impl Instant {

impl PartialOrd for Instant {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
match (self, other) {
(Instant::Real(this), Instant::Real(other)) => this.partial_cmp(other),
#[cfg(feature = "mock")]
(Instant::Mock(this), Instant::Mock(other)) => this.partial_cmp(other),
#[cfg(feature = "mock")]
_ => panic!("Instants weren't compatible, both need to be either real or mocked"),
}
Some(self.cmp(other))
}
}

Expand Down
8 changes: 4 additions & 4 deletions async-time-mock-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "async-time-mock-core"
description = "Mockable time for use in async runtimes (core package)."
version = "0.1.0"
version = "0.1.1"
edition = "2021"
license = "MIT"
authors = [
Expand All @@ -11,10 +11,10 @@ authors = [
rust-version = "1.64"

[dependencies]
async-lock = "2"
event-listener = "2"
async-lock = { version = "3", default-features = false }
event-listener = { version = "3", default-features = false }
pin-project-lite = "0.2"

[dev-dependencies]
futures-lite = {version = "1", default-features = false}
futures-lite = { version = "2", default-features = false }
tokio = {version = "1", features = ["rt", "macros"]}
3 changes: 2 additions & 1 deletion async-time-mock-core/src/time_handler_guard.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use event_listener::{Event, EventListener};
use std::pin::Pin;

#[must_use = "TimeHandlerGuard must be kept until the timer has performed it's side-effects"]
pub struct TimeHandlerGuard(Event);
Expand All @@ -17,7 +18,7 @@ impl Drop for TimeHandlerGuard {
}
}

pub(crate) struct TimeHandlerFinished(EventListener);
pub(crate) struct TimeHandlerFinished(Pin<Box<EventListener>>);

impl TimeHandlerFinished {
pub(crate) async fn wait(self) {
Expand Down
3 changes: 2 additions & 1 deletion async-time-mock-core/src/timer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::time_handler_guard::TimeHandlerFinished;
use crate::TimeHandlerGuard;
use event_listener::{Event, EventListener};
use std::pin::Pin;

pub(crate) struct Timer {
trigger: Event,
Expand Down Expand Up @@ -35,7 +36,7 @@ impl Timer {
}

pub(crate) struct TimerListener {
listener: EventListener,
listener: Pin<Box<EventListener>>,
handler_guard: TimeHandlerGuard,
}

Expand Down
2 changes: 1 addition & 1 deletion async-time-mock-core/src/timer_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl TimerRegistry {

fn schedule_timer(mut timers_by_time: RwLockWriteGuard<'_, TimersByTime>, at: Duration) -> TimerListener {
let (timer, listener) = Timer::new();
timers_by_time.entry(at).or_insert_with(VecDeque::new).push_back(timer);
timers_by_time.entry(at).or_default().push_back(timer);
listener
}

Expand Down
8 changes: 1 addition & 7 deletions async-time-mock-smol/src/instant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,7 @@ impl Instant {

impl PartialOrd for Instant {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
match (self, other) {
(Instant::Real(this), Instant::Real(other)) => this.partial_cmp(other),
#[cfg(feature = "mock")]
(Instant::Mock(this), Instant::Mock(other)) => this.partial_cmp(other),
#[cfg(feature = "mock")]
_ => panic!("Instants weren't compatible, both need to be either real or mocked"),
}
Some(self.cmp(other))
}
}

Expand Down
8 changes: 1 addition & 7 deletions async-time-mock-tokio/src/instant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,7 @@ impl Instant {

impl PartialOrd for Instant {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
match (self, other) {
(Instant::Real(this), Instant::Real(other)) => this.partial_cmp(other),
#[cfg(feature = "mock")]
(Instant::Mock(this), Instant::Mock(other)) => this.partial_cmp(other),
#[cfg(feature = "mock")]
_ => panic!("Instants weren't compatible, both need to be either real or mocked"),
}
Some(self.cmp(other))
}
}

Expand Down

0 comments on commit 428bb9b

Please sign in to comment.