@@ -833,6 +833,7 @@ pub trait Listener<T>: Future<Output = T> + __sealed::Sealed {
833
833
fn same_event ( & self , other : & Self ) -> bool ;
834
834
}
835
835
836
+ /// Implement the `Listener` trait using the underlying `InnerListener`.
836
837
macro_rules! forward_impl_to_listener {
837
838
( $gen: ident => $ty: ty) => {
838
839
impl <$gen> crate :: Listener <$gen> for $ty {
@@ -869,6 +870,15 @@ macro_rules! forward_impl_to_listener {
869
870
core:: ptr:: eq:: <Inner <$gen>>( & * self . listener( ) . event, & * other. listener( ) . event)
870
871
}
871
872
}
873
+
874
+ impl <$gen> Future for $ty {
875
+ type Output = $gen;
876
+
877
+ #[ inline]
878
+ fn poll( mut self : Pin <& mut Self >, cx: & mut Context <' _>) -> Poll <$gen> {
879
+ self . listener_mut( ) . poll_internal( cx)
880
+ }
881
+ }
872
882
} ;
873
883
}
874
884
@@ -922,14 +932,6 @@ impl<T> EventListener<T> {
922
932
923
933
forward_impl_to_listener ! { T => EventListener <T > }
924
934
925
- impl < T > Future for EventListener < T > {
926
- type Output = T ;
927
-
928
- fn poll ( mut self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Self :: Output > {
929
- self . listener . as_mut ( ) . poll_internal ( cx)
930
- }
931
- }
932
-
933
935
/// Create a stack-based event listener for an [`Event`].
934
936
#[ macro_export]
935
937
macro_rules! listener {
@@ -1376,13 +1378,4 @@ pub mod __private {
1376
1378
}
1377
1379
1378
1380
forward_impl_to_listener ! { T => StackListener <' _, ' _, T > }
1379
-
1380
- impl < T > Future for StackListener < ' _ , ' _ , T > {
1381
- type Output = T ;
1382
-
1383
- #[ inline]
1384
- fn poll ( mut self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Self :: Output > {
1385
- self . listener_mut ( ) . poll_internal ( cx)
1386
- }
1387
- }
1388
1381
}
0 commit comments