Function confirm

Source
pub fn confirm(message: impl Display) -> bool
Expand description

Prompts the user for confirmation with a custom message. Returns true if the user confirms, false otherwise.

Accepts various forms of input:

  • Yes: “y”, “Y”, “yes”, “Yes”, “YES”
  • No: “n”, “N”, “no”, “No”, “NO”, “” (empty input), literally anything else than yes

§Arguments

  • message - The message to display before “ y/N: “

§Examples

use netpulse::common::confirm;
if confirm("Delete all files") {
    println!("Deleting...");
} else {
    println!("Operation cancelled");
}