Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 58c47d1

Browse files
committed
refactor
1 parent 2566045 commit 58c47d1

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

‎src/main.rs‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,18 @@ fn main() {
9292
continue;
9393
}
9494
}
95-
95+
let mut problem_stat: Option<StatWithStatus> = None;
96+
for p in fetcher::get_problems().unwrap().stat_status_pairs {
97+
if p.stat.frontend_question_id == id {
98+
problem_stat = Some(p);
99+
}
100+
}
101+
if problem_stat.is_none() {
102+
println!("Problem {} does not exist", id);
103+
continue;
104+
}
96105
let problem =
97-
fetcher::get_problem(&get_problem_stat_map(fetcher::get_problems().unwrap())[&id])
106+
fetcher::get_problem(&problem_stat.unwrap())
98107
.unwrap_or_else(|| {
99108
panic!(
100109
"Error: failed to get problem #{} (The problem may be paid-only or may not be exist).",
@@ -325,14 +334,6 @@ async fn deal_problem(problem_stat: StatWithStatus) {
325334
);
326335
}
327336

328-
pub fn get_problem_stat_map(problems: Problems) -> HashMap<u32, StatWithStatus> {
329-
let mut ret = HashMap::new();
330-
for problem_stat in problems.stat_status_pairs {
331-
ret.insert(problem_stat.stat.frontend_question_id, problem_stat);
332-
}
333-
ret
334-
}
335-
336337
// extract common code
337338
pub fn get_file_name(problem: &Problem, prefix: &str) -> String {
338339
format!(

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /