@@ -110,16 +110,14 @@ pub fn get_question_msg(name: &str) -> Resp {
110110 let url = "https://leetcode-cn.com/graphql/" ;
111111 let data_fmt = r#"{"operationName":"questionData","variables":{"titleSlug":"{}"},"query":"query questionData($titleSlug: String!) {\n question(titleSlug: $titleSlug) {\n questionId\n questionFrontendId\n boundTopicId\n title\n titleSlug\n content\n translatedTitle\n translatedContent\n isPaidOnly\n difficulty\n likes\n dislikes\n isLiked\n similarQuestions\n contributors {\n username\n profileUrl\n avatarUrl\n __typename\n }\n langToValidPlayground\n topicTags {\n name\n slug\n translatedName\n __typename\n }\n companyTagStats\n codeSnippets {\n lang\n langSlug\n code\n __typename\n }\n stats\n hints\n solution {\n id\n canSeeDetail\n __typename\n }\n status\n sampleTestCase\n metaData\n judgerAvailable\n judgeType\n mysqlSchemas\n enableRunCode\n envInfo\n book {\n id\n bookName\n pressName\n source\n shortDescription\n fullDescription\n bookImgUrl\n pressImgUrl\n productUrl\n __typename\n }\n isSubscribed\n isDailyQuestion\n dailyRecordStatus\n editorType\n ugcQuestionId\n style\n __typename\n }\n}\n"}"# ;
112112 let data = data_fmt. replace ( "{}" , name) ;
113- let res = reqwest:: blocking:: Client :: new ( )
113+ reqwest:: blocking:: Client :: new ( )
114114 . post ( url)
115115 . header ( "content-type" , "application/json" )
116116 . body ( data)
117117 . send ( )
118118 . unwrap ( )
119119 . json :: < Resp > ( )
120- . unwrap ( ) ;
121-
122- res
120+ . unwrap ( )
123121}
124122
125123/// 把问题写到README.md中
@@ -133,7 +131,7 @@ pub fn write_to_readme(question_info: Resp) {
133131 let mut f = File :: create ( "README.md" ) . unwrap ( ) ;
134132
135133 let mut index = 0usize ;
136- let split = readme. split ( " \n " ) . into_iter ( ) . collect :: < Vec < & str > > ( ) ;
134+ let split = readme. split ( '\n' ) . into_iter ( ) . collect :: < Vec < & str > > ( ) ;
137135 let mut flag = false ;
138136 let mut flag1 = false ;
139137 let no = question_info
@@ -164,21 +162,21 @@ pub fn write_to_readme(question_info: Resp) {
164162 "- {}:{}\n " ,
165163 no, question_info. data. question. translated_title
166164 )
167- . as_str ( ) ,
165+ . as_str ( ) ,
168166 ) ;
169167 write_string. push_str (
170168 format ! (
171169 " - [src](https://github.com/rustors/leetcode/blob/main/src/bin/{}.rs)\n " ,
172170 question_info. data. question. title_slug
173171 )
174- . as_str ( ) ,
172+ . as_str ( ) ,
175173 ) ;
176174 write_string. push_str (
177175 format ! (
178176 " - [leetcode](https://leetcode-cn.com/problems/{}/)\n " ,
179177 question_info. data. question. title_slug
180178 )
181- . as_str ( ) ,
179+ . as_str ( ) ,
182180 ) ;
183181 }
184182
@@ -189,7 +187,7 @@ pub fn write_to_readme(question_info: Resp) {
189187 split[ index + 1 ] ,
190188 split[ index + 2 ]
191189 )
192- . as_str ( ) ,
190+ . as_str ( ) ,
193191 ) ;
194192 index += 3 ;
195193 }
@@ -200,21 +198,21 @@ pub fn write_to_readme(question_info: Resp) {
200198 "- {}:{}\n " ,
201199 no, question_info. data. question. translated_title
202200 )
203- . as_str ( ) ,
201+ . as_str ( ) ,
204202 ) ;
205203 write_string. push_str (
206204 format ! (
207205 " - [src](https://github.com/rustors/leetcode/blob/main/src/bin/{}.rs)\n " ,
208206 question_info. data. question. title_slug
209207 )
210- . as_str ( ) ,
208+ . as_str ( ) ,
211209 ) ;
212210 write_string. push_str (
213211 format ! (
214212 " - [leetcode](https://leetcode-cn.com/problems/{}/)\n " ,
215213 question_info. data. question. title_slug
216214 )
217- . as_str ( ) ,
215+ . as_str ( ) ,
218216 ) ;
219217 }
220218
@@ -238,7 +236,7 @@ fn get_question_num() -> usize {
238236
239237/// 获取题目的编号
240238fn get_question_no ( s : & str ) -> i32 {
241- s. split ( ":" ) . into_iter ( ) . collect :: < Vec < & str > > ( ) [ 0 ]
239+ s. split ( ':' ) . into_iter ( ) . collect :: < Vec < & str > > ( ) [ 0 ]
242240 . trim_end_matches ( ':' )
243241 . trim_start_matches ( '-' )
244242 . trim_start ( )
@@ -290,5 +288,5 @@ pub fn make_new_file(resp: Resp) {
290288 }
291289 }
292290
293- f. write ( s. as_bytes ( ) ) . unwrap ( ) ;
291+ f. write_all ( s. as_bytes ( ) ) . unwrap ( ) ;
294292}
0 commit comments