@@ -57,7 +57,7 @@ enum State<'a, T> {
57
57
} ,
58
58
ReadLine {
59
59
read_line : Pin < Box < dyn Future < Output = ReadLineResult < ' a > > + ' a > > ,
60
- parent_inactive : * mut StreamingPeekableIter < T > ,
60
+ parent_inactive : Option < * mut StreamingPeekableIter < T > > ,
61
61
} ,
62
62
}
63
63
@@ -138,18 +138,25 @@ where
138
138
let ( ofs, cap) = loop {
139
139
match this. state {
140
140
State :: Idle { ref mut parent } => {
141
- let parent = parent. take ( ) . unwrap ( ) ;
141
+ let parent = parent. take ( ) . expect ( "parent to be present here" ) ;
142
142
let inactive = parent as * mut _ ;
143
143
this. state = State :: ReadLine {
144
144
read_line : parent. read_line ( ) . boxed ( ) ,
145
- parent_inactive : inactive,
145
+ parent_inactive : Some ( inactive) ,
146
146
}
147
147
}
148
148
State :: ReadLine {
149
149
ref mut read_line,
150
- parent_inactive : _ ,
150
+ ref mut parent_inactive ,
151
151
} => {
152
- let line = match ready ! ( read_line. poll( cx) ) {
152
+ let line = ready ! ( read_line. poll( cx) ) ;
153
+
154
+ let parent = parent_inactive. take ( ) . expect ( "parent pointer always set" ) ;
155
+ #[ allow( unsafe_code) ]
156
+ let parent = unsafe { & mut * parent } ;
157
+ this. state = State :: Idle { parent : Some ( parent) } ;
158
+
159
+ let line = match line {
153
160
Some ( line) => line?. map_err ( |err| io:: Error :: new ( io:: ErrorKind :: Other , err) ) ?,
154
161
None => break ( 0 , 0 ) ,
155
162
} ;
@@ -191,8 +198,8 @@ where
191
198
}
192
199
}
193
200
let range = self . pos ..self . cap ;
194
- match self . get_mut ( ) . state {
195
- State :: Idle { ref parent } => Poll :: Ready ( Ok ( & parent. as_ref ( ) . unwrap ( ) . buf [ range] ) ) ,
201
+ match & self . get_mut ( ) . state {
202
+ State :: Idle { parent } => Poll :: Ready ( Ok ( & parent. as_ref ( ) . expect ( "parent always available" ) . buf [ range] ) ) ,
196
203
State :: ReadLine { .. } => unreachable ! ( "at least in theory" ) ,
197
204
}
198
205
}
0 commit comments