Make prompt_yes more generic

This commit is contained in:
Kevin Liu 2016-11-04 08:42:22 -07:00
parent 132eebd4d9
commit 33299946aa
2 changed files with 3 additions and 3 deletions

View file

@ -191,7 +191,7 @@ Send files to the graveyard (/tmp/.graveyard by default) instead of unlinking th
println!("Error reading {}", source.display());
}
}
if !prompt_yes(&format!("Send {} to the graveyard?", target)) {
if !prompt_yes(format!("Send {} to the graveyard?", target)) {
continue;
}
}

View file

@ -7,8 +7,8 @@ fn get_user() -> String {
}
/// Prompt for user input, returning True if the first character is 'y' or 'Y'
fn prompt_yes(prompt: &str) -> bool {
print!("{} (y/N) ", prompt);
fn prompt_yes<T: AsRef<str>>(prompt: T) -> bool {
print!("{} (y/N) ", prompt.as_ref());
io::stdout().flush().unwrap();
let stdin = BufReader::new(io::stdin());
if let Some(c) = stdin.chars().next() {