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 17fcf95

Browse files
fix: use get_problem_id_from_name()
1 parent 319055b commit 17fcf95

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

‎src/cmds/pick.rs‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ impl Command for PickCommand {
139139
//check for name specified
140140
true => {
141141
match m.get_one::<String>("name").map(|name| name) {
142-
Some(quesname) => match cache.get_problem_from_name(quesname) {
143-
Ok(p) => p.fid,
142+
Some(quesname) => match cache.get_problem_id_from_name(quesname) {
143+
Ok(p) => p,
144144
Err(_) => 1,
145145
},
146146
None => {
@@ -158,18 +158,11 @@ impl Command for PickCommand {
158158
// Pick random without specify id
159159
let problem = &problems[rand::thread_rng().gen_range(0..problems.len())];
160160
problem.fid
161-
});
162-
163-
let id = match fid {
164-
Ok(id) => id,
165-
Err(_) => {
166-
// Pick random without specify id
167-
let problem = &problems[rand::thread_rng().gen_range(0..problems.len())];
168-
problem.fid
161+
})
169162
}
170163
};
171164

172-
let r = cache.get_question(id).await;
165+
let r = cache.get_question(fid).await;
173166

174167
match r {
175168
Ok(q) => println!("{}", q.desc()),

0 commit comments

Comments
(0)

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