pub fn read_from_cli(prompt: &str) -> io::Result<Self> {
        let mut buf = String::new();
        loop {
            print!("{} (y/n) ", prompt);
            io::stdout().flush()?;

            io::stdin().read_line(&mut buf)?;
            buf = buf.trim().to_lowercase();

            if buf.is_empty() {
                continue;
            }

            if buf.starts_with("yes") || "yes".starts_with(&buf) {
                return Ok(Yes);
            } else if buf.starts_with("no") || "no".starts_with(&buf) {
                return Ok(No);
            } else {
                buf.clear();
                continue;
            }
        }
    }
/// Prompts the user with `prompt` and asks for a yes/no answer.
/// Will continue asking until input resembling yes/no is given.
Prompts the user with `prompt` and asks for a yes/no answer.
Will continue asking until input resembling yes/no is given.
Prompts the user with ` prompt ` and asks for a yes / no answer . Will continue asking until input resembling yes / no is given .
pub fn read_from_cli(prompt: &str) -> io::Result<Self> {
        let mut buf = String::new();
        loop {
            print!("{} (y/n) ", prompt);
            io::stdout().flush()?;
            io::stdin().read_line(&mut buf)?;
            buf = buf.trim().to_lowercase();
            if buf.is_empty() {
                continue;
            }
            if buf.starts_with("yes") || "yes".starts_with(&buf) {
                return Ok(Yes);
            } else if buf.starts_with("no") || "no".starts_with(&buf) {
                return Ok(No);
            } else {
                buf.clear();
                continue;
            }
        }
    }
pub fn read_from_cli ( prompt : & str ) -> io :: Result < Self > { let mut buf = String :: new ( ) ; loop { print ! ( " " prompt ) ; io :: stdout ( ) . flush ( ) ? ; io :: stdin ( ) . read_line ( & mut buf ) ? ; buf = buf . trim ( ) . to_lowercase ( ) ; if buf . is_empty ( ) { continue ; } if buf . starts_with ( " " ) || " " . starts_with ( & buf ) { return Ok ( Yes ) ; } else if buf . starts_with ( " " ) || " " . starts_with ( & buf ) { return Ok ( No ) ; } else { buf . clear ( ) ; continue ; } } }
Prompts the user with `prompt` and asks for a yes/no answer.
Prompts the user with ` prompt ` and asks for a yes / no answer .
prompt
&str
prompt
&str