mirror of
https://github.com/nivekuil/rip
synced 2024-11-29 07:00:20 +00:00
Make prompt_yes more generic
This commit is contained in:
parent
132eebd4d9
commit
33299946aa
2 changed files with 3 additions and 3 deletions
|
@ -191,7 +191,7 @@ Send files to the graveyard (/tmp/.graveyard by default) instead of unlinking th
|
||||||
println!("Error reading {}", source.display());
|
println!("Error reading {}", source.display());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !prompt_yes(&format!("Send {} to the graveyard?", target)) {
|
if !prompt_yes(format!("Send {} to the graveyard?", target)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@ fn get_user() -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Prompt for user input, returning True if the first character is 'y' or 'Y'
|
/// Prompt for user input, returning True if the first character is 'y' or 'Y'
|
||||||
fn prompt_yes(prompt: &str) -> bool {
|
fn prompt_yes<T: AsRef<str>>(prompt: T) -> bool {
|
||||||
print!("{} (y/N) ", prompt);
|
print!("{} (y/N) ", prompt.as_ref());
|
||||||
io::stdout().flush().unwrap();
|
io::stdout().flush().unwrap();
|
||||||
let stdin = BufReader::new(io::stdin());
|
let stdin = BufReader::new(io::stdin());
|
||||||
if let Some(c) = stdin.chars().next() {
|
if let Some(c) = stdin.chars().next() {
|
||||||
|
|
Loading…
Reference in a new issue