• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #[test]
ignore_err()2 fn ignore_err() {
3     use futures::executor::block_on;
4     use futures::future::{err, ok, select_ok};
5 
6     let v = vec![
7         err(1),
8         err(2),
9         ok(3),
10         ok(4),
11     ];
12 
13     let (i, v) = block_on(select_ok(v)).ok().unwrap();
14     assert_eq!(i, 3);
15 
16     assert_eq!(v.len(), 1);
17 
18     let (i, v) = block_on(select_ok(v)).ok().unwrap();
19     assert_eq!(i, 4);
20 
21     assert!(v.is_empty());
22 }
23 
24 #[test]
last_err()25 fn last_err() {
26     use futures::executor::block_on;
27     use futures::future::{err, ok, select_ok};
28 
29     let v = vec![
30         ok(1),
31         err(2),
32         err(3),
33     ];
34 
35     let (i, v) = block_on(select_ok(v)).ok().unwrap();
36     assert_eq!(i, 1);
37 
38     assert_eq!(v.len(), 2);
39 
40     let i = block_on(select_ok(v)).err().unwrap();
41     assert_eq!(i, 3);
42 }
43