tuwunel_core/utils/future/
ready_eq_ext.rs1use futures::{Future, FutureExt};
4
5pub trait ReadyEqExt<T>
6where
7 Self: Future<Output = T> + Send + Sized,
8 T: PartialEq + Send + Sync,
9{
10 fn eq(self, t: &T) -> impl Future<Output = bool> + Send;
11
12 fn ne(self, t: &T) -> impl Future<Output = bool> + Send;
13}
14
15impl<Fut, T> ReadyEqExt<T> for Fut
16where
17 Fut: Future<Output = T> + Send + Sized,
18 T: PartialEq + Send + Sync,
19{
20 #[inline]
21 fn eq(self, t: &T) -> impl Future<Output = bool> + Send { self.map(move |r| r.eq(t)) }
22
23 #[inline]
24 fn ne(self, t: &T) -> impl Future<Output = bool> + Send { self.map(move |r| r.ne(t)) }
25}