@@ -188,6 +188,17 @@ fn parse_extra_use(code: &str) -> String {
188
188
extra_use_line
189
189
}
190
190
191
+ fn parse_problem_link ( problem : & Problem ) -> String {
192
+ format ! ( "https://leetcode.com/problems/{}/" , problem. title_slug)
193
+ }
194
+
195
+ fn parse_discuss_link ( problem : & Problem ) -> String {
196
+ format ! (
197
+ "https://leetcode.com/problems/{}/discuss/?currentPage=1&orderBy=most_votes&query=" ,
198
+ problem. title_slug
199
+ )
200
+ }
201
+
191
202
fn insert_return_in_code ( return_type : & str , code : & str ) -> String {
192
203
let re = Regex :: new ( r"\{[ \n]+}" ) . unwrap ( ) ;
193
204
match return_type {
@@ -326,7 +337,9 @@ fn deal_problem(problem: &Problem, code: &CodeDefinition, write_mod_file: bool)
326
337
& insert_return_in_code ( & problem. return_type , & code. default_code ) ,
327
338
)
328
339
. replace ( "__PROBLEM_ID__" , & format ! ( "{}" , problem. question_id) )
329
- . replace ( "__EXTRA_USE__" , & parse_extra_use ( & code. default_code ) ) ;
340
+ . replace ( "__EXTRA_USE__" , & parse_extra_use ( & code. default_code ) )
341
+ . replace ( "__PROBLEM_LINK__" , & parse_problem_link ( problem) )
342
+ . replace ( "__DISCUSS_LINK__" , & parse_discuss_link ( problem) ) ;
330
343
331
344
let mut file = fs:: OpenOptions :: new ( )
332
345
. write ( true )
0 commit comments