@@ -8,7 +8,6 @@ use crate::openapi;
8
8
use anyhow:: Result ;
9
9
use serde:: { Deserialize , Serialize } ;
10
10
use std:: ops:: ControlFlow ;
11
- use crate :: api:: ing:: get_comment_list:: IngCommentEntry ;
12
11
13
12
#[ derive( Clone , Debug , Serialize , Deserialize ) ]
14
13
pub struct IngEntry {
@@ -40,15 +39,13 @@ pub struct IngEntry {
40
39
pub icons : String ,
41
40
}
42
41
43
- type IngEntryWithComment = ( IngEntry , Vec < IngCommentEntry > ) ;
44
-
45
42
impl Ing {
46
43
pub async fn get_list (
47
44
& self ,
48
45
skip : usize ,
49
46
take : usize ,
50
47
ing_type : & IngType ,
51
- ) -> Result < Vec < IngEntryWithComment > > {
48
+ ) -> Result < Vec < IngEntry > > {
52
49
let client = & reqwest:: Client :: new ( ) ;
53
50
54
51
let range = ( skip + 1 ) ..=( skip + take) ;
@@ -64,27 +61,15 @@ impl Ing {
64
61
65
62
let body = body_or_err ( resp) . await ?;
66
63
67
- let entry_with_comment = {
68
- match json:: deserialize :: < Vec < IngEntry > > ( & body) ?. pop ( ) {
69
- Some ( entry) => {
70
- let id = entry. id ;
71
- let comment_vec = self . get_comment_list ( id) . await ?;
72
-
73
- ControlFlow :: Continue ( ( entry, comment_vec) )
74
- }
75
- None => ControlFlow :: Break ( ( ) ) ,
76
- }
77
- } ;
78
-
79
- entry_with_comment. into_ok :: < anyhow:: Error > ( )
64
+ json:: deserialize :: < Vec < IngEntry > > ( & body) ?. pop ( ) . into_ok ( )
80
65
} )
81
66
. join_all ( )
82
67
. await
83
68
. into_iter ( )
84
69
. try_fold ( vec ! [ ] , |acc, it| match it {
85
- Ok ( cf ) => match cf {
86
- ControlFlow :: Continue ( it ) => ControlFlow :: Continue ( acc. chain_push ( it ) ) ,
87
- _ => ControlFlow :: Break ( Ok ( acc) ) ,
70
+ Ok ( maybe ) => match maybe {
71
+ Some ( entry ) => ControlFlow :: Continue ( acc. chain_push ( entry ) ) ,
72
+ None => ControlFlow :: Break ( Ok ( acc) ) ,
88
73
} ,
89
74
Err ( e) => ControlFlow :: Break ( Err ( e) ) ,
90
75
} ) ;
0 commit comments