@@ -120,7 +120,7 @@ fn main() {
120120 } else {
121121 _id = id_arg
122122 . parse :: < u32 > ( )
123- . unwrap_or_else ( |_| panic ! ( "not a number: {}" , id_arg ) ) ;
123+ . unwrap_or_else ( |_| panic ! ( "not a number: {id_arg}" ) ) ;
124124 if initialized_ids. contains ( & _id) {
125125 println ! ( "The problem you chose has been initialized in problem/" ) ;
126126 continue ;
@@ -129,9 +129,8 @@ fn main() {
129129
130130 let problem = fetcher:: get_problem ( _id) . unwrap_or_else ( || {
131131 panic ! (
132- "Error: failed to get problem #{} \
133- (The problem may be paid-only or may not be exist).",
134- _id
132+ "Error: failed to get problem #{_id} \
133+ (The problem may be paid-only or may not be exist)."
135134 )
136135 } ) ;
137136 let code = problem. code_definition . iter ( ) . find ( |& d| d. value == * "rust" ) ;
@@ -157,9 +156,8 @@ fn generate_random_id(except_ids: &[u32]) -> u32 {
157156 return res;
158157 }
159158 println ! (
160- "Generate a random num ({}), but it is invalid (the problem may have been solved \
161- or may have no rust version). Regenerate..",
162- res
159+ "Generate a random num ({res}), but it is invalid (the problem may have been solved \
160+ or may have no rust version). Regenerate.."
163161 ) ;
164162 }
165163}
@@ -291,7 +289,7 @@ fn deal_solving(id: &u32) {
291289 problem. question_id,
292290 problem. title_slug. replace( '-' , "_" )
293291 ) ;
294- let file_path = Path :: new ( "./src/problem" ) . join ( format ! ( "{}.rs" , file_name ) ) ;
292+ let file_path = Path :: new ( "./src/problem" ) . join ( format ! ( "{file_name }.rs" ) ) ;
295293 // check problem/ existence
296294 if !file_path. exists ( ) {
297295 panic ! ( "problem does not exist" ) ;
@@ -302,15 +300,15 @@ fn deal_solving(id: &u32) {
302300 problem. question_id,
303301 problem. title_slug. replace( '-' , "_" )
304302 ) ;
305- let solution_path = Path :: new ( "./src/solution" ) . join ( format ! ( "{}.rs" , solution_name ) ) ;
303+ let solution_path = Path :: new ( "./src/solution" ) . join ( format ! ( "{solution_name }.rs" ) ) ;
306304 if solution_path. exists ( ) {
307305 panic ! ( "solution exists" ) ;
308306 }
309307 // rename/move file
310308 fs:: rename ( file_path, solution_path) . unwrap ( ) ;
311309 // remove from problem/mod.rs
312310 let mod_file = "./src/problem/mod.rs" ;
313- let target_line = format ! ( "mod {};" , file_name ) ;
311+ let target_line = format ! ( "mod {file_name };" ) ;
314312 let lines: Vec < String > = io:: BufReader :: new ( File :: open ( mod_file) . unwrap ( ) )
315313 . lines ( )
316314 . map ( |x| x. unwrap ( ) )
@@ -322,7 +320,7 @@ fn deal_solving(id: &u32) {
322320 . append ( true )
323321 . open ( "./src/solution/mod.rs" )
324322 . unwrap ( ) ;
325- let _ = writeln ! ( lib_file, "mod {};" , solution_name ) ;
323+ let _ = writeln ! ( lib_file, "mod {solution_name };" ) ;
326324}
327325
328326fn deal_problem ( problem : & Problem , code : & CodeDefinition , write_mod_file : bool ) {
@@ -331,8 +329,7 @@ fn deal_problem(problem: &Problem, code: &CodeDefinition, write_mod_file: bool)
331329 problem. question_id,
332330 problem. title_slug. replace( '-' , "_" )
333331 ) ;
334- let file_path = Path :: new ( "./src/problem" ) . join ( format ! ( "{}.rs" , file_name) ) ;
335-
332+ let file_path = Path :: new ( "./src/problem" ) . join ( format ! ( "{file_name}.rs" ) ) ;
336333 let template = fs:: read_to_string ( "./template.rs" ) . unwrap ( ) ;
337334 let source = template
338335 . replace ( "__PROBLEM_TITLE__" , & problem. title )
@@ -361,7 +358,7 @@ fn deal_problem(problem: &Problem, code: &CodeDefinition, write_mod_file: bool)
361358 . append ( true )
362359 . open ( "./src/problem/mod.rs" )
363360 . unwrap ( ) ;
364- let _ = writeln ! ( lib_file, "pub mod {};" , file_name ) ;
361+ let _ = writeln ! ( lib_file, "pub mod {file_name };" ) ;
365362 }
366363}
367364
@@ -378,9 +375,9 @@ mod test {
378375 // pub mod p0001_two_sum;
379376 pub mod p0002_add_two_numbers;
380377 pub mod p0003_longest_substring_without_repeating_characters;"# ;
381- writeln ! ( file, "{}" , content ) . unwrap ( ) ;
378+ writeln ! ( file, "{content}" ) . unwrap ( ) ;
382379 let ids = get_initialized_ids ( path. to_str ( ) . unwrap ( ) ) ;
383- println ! ( "{:?}" , ids ) ;
380+ println ! ( "{ids :?}" ) ;
384381 assert ! ( ids. len( ) == 2 ) ;
385382 assert ! ( ids[ 0 ] == 2 ) ;
386383 assert ! ( ids[ 1 ] == 3 ) ;
0 commit comments