20241024 finished.
This commit is contained in:
12
src/main.rs
12
src/main.rs
@@ -1,7 +1,7 @@
|
||||
use crate::fetch_problem::{Fetcher, ProblemManager};
|
||||
use std::fs;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
use crate::fetch_problem::{Fetcher, ProblemManager};
|
||||
|
||||
mod fetch_problem;
|
||||
|
||||
@@ -22,12 +22,16 @@ async fn main() {
|
||||
|
||||
println!("Try to get problem {}...", id);
|
||||
|
||||
let problem = fetcher.get_problem(id).await
|
||||
let problem = fetcher
|
||||
.get_problem(id)
|
||||
.await
|
||||
.expect(&*format!("Failed to get problem {}.", id));
|
||||
|
||||
let file_name = problem.get_filename();
|
||||
println!("Get problem: {}.", file_name);
|
||||
let content = problem.get_file_content().expect("Failed to format file content");
|
||||
let content = problem
|
||||
.get_file_content()
|
||||
.expect("Failed to format file content");
|
||||
|
||||
write_file(&file_name, &content).expect("Failed to write problem file.");
|
||||
}
|
||||
@@ -55,4 +59,4 @@ fn write_file(file_name: &String, file_content: &String) -> std::io::Result<()>
|
||||
.open("./src/problem/mod.rs")?;
|
||||
|
||||
write!(mod_file, "\nmod {};", file_name)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user