Fix program not exiting on EOF during some prompts

This commit is contained in:
Hiers 2023-12-16 11:44:37 +00:00
parent 5501c621c9
commit 37e36db2a1

View file

@ -70,7 +70,9 @@ fn search_by_strokes(query: &mut String, radk_list: &[radk::Membership], n: usiz
print!("How many strokes does your radical have? "); print!("How many strokes does your radical have? ");
stdout().flush()?; stdout().flush()?;
strokes.clear(); strokes.clear();
stdin().read_line(&mut strokes)?; if stdin().read_line(&mut strokes)? == 0{
std::process::exit(0);
}
match strokes.trim().parse::<u8>() { match strokes.trim().parse::<u8>() {
Ok(strk) => { Ok(strk) => {
@ -89,7 +91,9 @@ fn search_by_strokes(query: &mut String, radk_list: &[radk::Membership], n: usiz
print!("Choose the radical to use for your search: "); print!("Choose the radical to use for your search: ");
stdout().flush()?; stdout().flush()?;
strokes.clear(); strokes.clear();
stdin().read_line(&mut strokes)?; if stdin().read_line(&mut strokes)? == 0{
std::process::exit(0);
}
match strokes.trim().parse::<usize>() { match strokes.trim().parse::<usize>() {
Ok(strk) => { Ok(strk) => {