mirror of
https://github.com/nivekuil/rip
synced 2024-11-10 06:04:17 +00:00
More monadic way of reading input
This commit is contained in:
parent
a04a905f60
commit
08429ed64c
1 changed files with 4 additions and 6 deletions
10
src/util.rs
10
src/util.rs
|
@ -26,12 +26,10 @@ fn prompt_yes<T: AsRef<str>>(prompt: T) -> bool {
|
|||
println!("{} (y/N)", prompt.as_ref());
|
||||
}
|
||||
let stdin = BufReader::new(io::stdin());
|
||||
if let Some(c) = stdin.chars().next() {
|
||||
if let Ok(c) = c {
|
||||
return c == 'y' || c == 'Y';
|
||||
}
|
||||
}
|
||||
false
|
||||
stdin.chars().next()
|
||||
.and_then(|c| c.ok())
|
||||
.and_then(|c| Some(c == 'y' || c == 'Y'))
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
/// Add a numbered extension to duplicate filenames to avoid overwriting files.
|
||||
|
|
Loading…
Reference in a new issue