aj_io_tools::input

Function read_line

Source
pub fn read_line(message: &str) -> String
Expand description

Scans the input to the console by first printing an invitation message to the console.

§Params

  • message: &str - Invitation message to the console.

§Returns

§Panics

If somehow failed to read line with stdin().read_line() function.

§Examples

use aj_io_tools::read_line;
 
let input = read_line("What's your name: ");
 
match input.as_str() {
    "Aleksey" => println!("You're Aleksey, glad to hear you!"),
    _ => println!("You're not Aleksey, but anuway I'm glad to hear you!")
}