Skip to content

Commit 319055b

Browse files
committed
Clean up ID selecting code
1 parent 06df7ea commit 319055b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/cmds/pick.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,17 @@ impl Command for PickCommand {
159159
let problem = &problems[rand::thread_rng().gen_range(0..problems.len())];
160160
problem.fid
161161
});
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
162169
}
163170
};
164171

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

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

0 commit comments

Comments
 (0)