@@ -2,6 +2,10 @@ use std::marker::PhantomData;
2
2
use std:: pin:: Pin ;
3
3
use std:: task:: { Context , Poll } ;
4
4
5
+ use crate :: future:: Future ;
6
+ use crate :: stream:: Stream ;
7
+
8
+ #[ doc( hidden) ]
5
9
#[ allow( missing_debug_implementations) ]
6
10
pub struct FindMapFuture < ' a , S , F , T , B > {
7
11
stream : & ' a mut S ,
@@ -11,9 +15,6 @@ pub struct FindMapFuture<'a, S, F, T, B> {
11
15
}
12
16
13
17
impl < ' a , S , B , F , T > FindMapFuture < ' a , S , F , T , B > {
14
- pin_utils:: unsafe_pinned!( stream: & ' a mut S ) ;
15
- pin_utils:: unsafe_unpinned!( f: F ) ;
16
-
17
18
pub ( super ) fn new ( stream : & ' a mut S , f : F ) -> Self {
18
19
FindMapFuture {
19
20
stream,
@@ -24,20 +25,20 @@ impl<'a, S, B, F, T> FindMapFuture<'a, S, F, T, B> {
24
25
}
25
26
}
26
27
27
- impl < ' a , S , B , F > futures_core:: future:: Future for FindMapFuture < ' a , S , F , S :: Item , B >
28
+ impl < S : Unpin , F , T , B > Unpin for FindMapFuture < ' _ , S , F , T , B > { }
29
+
30
+ impl < ' a , S , B , F > Future for FindMapFuture < ' a , S , F , S :: Item , B >
28
31
where
29
- S : futures_core :: stream :: Stream + Unpin + Sized ,
32
+ S : Stream + Unpin + Sized ,
30
33
F : FnMut ( S :: Item ) -> Option < B > ,
31
34
{
32
35
type Output = Option < B > ;
33
36
34
37
fn poll ( mut self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Self :: Output > {
35
- use futures_core:: stream:: Stream ;
36
-
37
- let item = futures_core:: ready!( self . as_mut( ) . stream( ) . poll_next( cx) ) ;
38
+ let item = futures_core:: ready!( Pin :: new( & mut * self . stream) . poll_next( cx) ) ;
38
39
39
40
match item {
40
- Some ( v) => match ( self . as_mut ( ) . f ( ) ) ( v) {
41
+ Some ( v) => match ( & mut self . f ) ( v) {
41
42
Some ( v) => Poll :: Ready ( Some ( v) ) ,
42
43
None => {
43
44
cx. waker ( ) . wake_by_ref ( ) ;
0 commit comments