File tree 1 file changed +11
-3
lines changed
1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -140,8 +140,7 @@ pub fn poll_fn<F, T>(f: F) -> impl Future<Output = T>
140
140
from_generator ( || {
141
141
let mut f = f;
142
142
loop {
143
- let poll_result = get_task_context ( |context : & mut Context | f ( context) ) ;
144
- match poll_result {
143
+ match get_task_context ( |context : & mut Context | f ( context) ) {
145
144
Poll :: Pending => yield ,
146
145
Poll :: Ready ( value) => return value,
147
146
}
@@ -181,14 +180,23 @@ mod tests {
181
180
}
182
181
183
182
#[ test]
184
- fn test_and_then ( ) {
183
+ fn test_and_then_ok ( ) {
185
184
executor:: block_on ( async {
186
185
let future = ready ( Ok :: < i32 , i32 > ( 1 ) ) ;
187
186
let new_future = and_then ( future, |x| ready ( Ok :: < i32 , i32 > ( x + 3 ) ) ) ;
188
187
assert_eq ! ( new_future. await , Ok ( 4 ) ) ;
189
188
} ) ;
190
189
}
191
190
191
+ #[ test]
192
+ fn test_and_then_err ( ) {
193
+ executor:: block_on ( async {
194
+ let future = ready ( Err :: < i32 , i32 > ( 1 ) ) ;
195
+ let new_future = and_then ( future, |x| ready ( Ok :: < i32 , i32 > ( x + 3 ) ) ) ;
196
+ assert_eq ! ( new_future. await , Err ( 1 ) ) ;
197
+ } ) ;
198
+ }
199
+
192
200
#[ test]
193
201
fn test_or_else ( ) {
194
202
executor:: block_on ( async {
You can’t perform that action at this time.
0 commit comments