@@ -80,11 +80,11 @@ mod notify;
80
80
81
81
use alloc:: boxed:: Box ;
82
82
83
+ use core:: borrow:: Borrow ;
83
84
use core:: fmt;
84
85
use core:: future:: Future ;
85
86
use core:: marker:: PhantomPinned ;
86
87
use core:: mem:: ManuallyDrop ;
87
- use core:: ops:: Deref ;
88
88
use core:: pin:: Pin ;
89
89
use core:: ptr;
90
90
use core:: task:: { Context , Poll , Waker } ;
@@ -99,7 +99,7 @@ use sync::{Arc, WithMut};
99
99
100
100
pub use notify:: { Additional , IntoNotification , Notification , Notify , Tag , TagWith } ;
101
101
102
- /// Useful trait for listeners .
102
+ /// Useful traits for notifications .
103
103
pub mod prelude {
104
104
pub use crate :: { IntoNotification , Notification } ;
105
105
}
@@ -129,7 +129,7 @@ struct Inner<T> {
129
129
list : sys:: List < T > ,
130
130
}
131
131
132
- impl < T : Unpin > Inner < T > {
132
+ impl < T > Inner < T > {
133
133
fn new ( ) -> Self {
134
134
Self {
135
135
notified : AtomicUsize :: new ( core:: usize:: MAX ) ,
@@ -180,14 +180,14 @@ impl<T> fmt::Debug for Event<T> {
180
180
}
181
181
}
182
182
183
- impl < T : Unpin > Default for Event < T > {
183
+ impl < T > Default for Event < T > {
184
184
#[ inline]
185
185
fn default ( ) -> Self {
186
186
Self :: with_tag ( )
187
187
}
188
188
}
189
189
190
- impl < T : Unpin > Event < T > {
190
+ impl < T > Event < T > {
191
191
/// Creates a new `Event` with a tag type.
192
192
///
193
193
/// # Examples
@@ -347,7 +347,7 @@ impl<T: Unpin> Event<T> {
347
347
348
348
if let Some ( inner) = self . try_inner ( ) {
349
349
let limit = if notify. is_additional ( ) {
350
- usize:: MAX
350
+ core :: usize:: MAX
351
351
} else {
352
352
notify. count ( )
353
353
} ;
@@ -600,15 +600,15 @@ impl<T> Drop for Event<T> {
600
600
/// If a notified listener is dropped without receiving a notification, dropping will notify
601
601
/// another active listener. Whether one *additional* listener will be notified depends on what
602
602
/// kind of notification was delivered.
603
- pub struct EventListener < T : Unpin = ( ) > ( Listener < T , Arc < Inner < T > > > ) ;
603
+ pub struct EventListener < T = ( ) > ( Listener < T , Arc < Inner < T > > > ) ;
604
604
605
- impl < T : Unpin > fmt:: Debug for EventListener < T > {
605
+ impl < T > fmt:: Debug for EventListener < T > {
606
606
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
607
607
f. write_str ( "EventListener { .. }" )
608
608
}
609
609
}
610
610
611
- impl < T : Unpin > EventListener < T > {
611
+ impl < T > EventListener < T > {
612
612
/// Create a new `EventListener` that will wait for a notification from the given [`Event`].
613
613
pub fn new ( event : & Event < T > ) -> Self {
614
614
let inner = event. inner ( ) ;
@@ -762,15 +762,15 @@ impl<T: Unpin> EventListener<T> {
762
762
}
763
763
}
764
764
765
- impl < T : Unpin > Future for EventListener < T > {
765
+ impl < T > Future for EventListener < T > {
766
766
type Output = T ;
767
767
768
768
fn poll ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Self :: Output > {
769
769
self . listener ( ) . poll_internal ( cx)
770
770
}
771
771
}
772
772
773
- struct Listener < T : Unpin , B : Deref < Target = Inner < T > > + Unpin > {
773
+ struct Listener < T , B : Borrow < Inner < T > > + Unpin > {
774
774
/// The reference to the original event.
775
775
event : B ,
776
776
@@ -781,10 +781,10 @@ struct Listener<T: Unpin, B: Deref<Target = Inner<T>> + Unpin> {
781
781
_pin : PhantomPinned ,
782
782
}
783
783
784
- unsafe impl < T : Send + Unpin , B : Deref < Target = Inner < T > > + Unpin + Send > Send for Listener < T , B > { }
785
- unsafe impl < T : Send + Unpin , B : Deref < Target = Inner < T > > + Unpin + Sync > Sync for Listener < T , B > { }
784
+ unsafe impl < T : Send , B : Borrow < Inner < T > > + Unpin + Send > Send for Listener < T , B > { }
785
+ unsafe impl < T : Send , B : Borrow < Inner < T > > + Unpin + Sync > Sync for Listener < T , B > { }
786
786
787
- impl < T : Unpin , B : Deref < Target = Inner < T > > + Unpin > Listener < T , B > {
787
+ impl < T , B : Borrow < Inner < T > > + Unpin > Listener < T , B > {
788
788
/// Pin-project this listener.
789
789
fn project ( self : Pin < & mut Self > ) -> ( & Inner < T > , Pin < & mut Option < sys:: Listener < T > > > ) {
790
790
// SAFETY: `event` is `Unpin`, and `listener`'s pin status is preserved
@@ -793,7 +793,7 @@ impl<T: Unpin, B: Deref<Target = Inner<T>> + Unpin> Listener<T, B> {
793
793
event, listener, ..
794
794
} = self . get_unchecked_mut ( ) ;
795
795
796
- ( & * event, Pin :: new_unchecked ( listener) )
796
+ ( ( * event) . borrow ( ) , Pin :: new_unchecked ( listener) )
797
797
}
798
798
}
799
799
@@ -910,7 +910,7 @@ impl<T: Unpin, B: Deref<Target = Inner<T>> + Unpin> Listener<T, B> {
910
910
}
911
911
}
912
912
913
- impl < T : Unpin , B : Deref < Target = Inner < T > > + Unpin > Drop for Listener < T , B > {
913
+ impl < T , B : Borrow < Inner < T > > + Unpin > Drop for Listener < T , B > {
914
914
fn drop ( & mut self ) {
915
915
// If we're being dropped, we need to remove ourself from the list.
916
916
let ( inner, listener) = unsafe { Pin :: new_unchecked ( self ) . project ( ) } ;
@@ -949,6 +949,7 @@ impl<T> State<T> {
949
949
}
950
950
951
951
/// If this state was notified, return the tag associated with the notification.
952
+ #[ allow( unused) ]
952
953
fn notified ( self ) -> Option < T > {
953
954
match self {
954
955
Self :: Notified { tag, .. } => Some ( tag) ,
0 commit comments