use futures::future::BoxFuture;
pub trait AsyncPartialEq<Rhs: ?Sized + Send + Sync = Self>
where
Self: Send + Sync,
{
fn eq<'a>(&'a self, other: &'a Rhs) -> BoxFuture<'a, bool>;
fn ne<'a>(&'a self, other: &'a Rhs) -> BoxFuture<'a, bool>
where
Self: 'a,
{
Box::pin(async move { !self.eq(other).await })
}
}
pub trait AsyncEq: AsyncPartialEq {}
impl<T> AsyncPartialEq<T> for T
where
T: PartialEq + Send + Sync,
{
fn eq<'a>(&'a self, other: &'a T) -> BoxFuture<'a, bool> {
Box::pin(async move { self == other })
}
}
#[macro_export]
macro_rules! async_assert {
($lhs:expr, $rhs:expr) => {
assert!($lhs.await)
};
}
#[macro_export]
macro_rules! async_assert_eq {
($lhs:expr, $rhs:expr) => {
assert!($lhs.eq($rhs).await)
};
}
#[macro_export]
macro_rules! async_assert_ne {
($lhs:expr, $rhs:expr) => {
assert!($lhs.ne($rhs).await)
};
}