pub fn input(comment: &str) -> Result<String, InputError>Expand description
Reads a line of input from stdin with a prompt, similar to Python’s input() function.
§Arguments
comment- The prompt text to display before the colon. If empty, no prompt is shown.
§Returns
Ok(String)- The input string with leading/trailing whitespace removedErr(InputError)- An error if stdout flush or stdin read fails
§Examples
use input_py::input;
// Basic usage with prompt
match input("Enter your name") {
Ok(name) => println!("Hello, {}!", name),
Err(e) => eprintln!("Error: {}", e),
}
// Empty prompt
match input("") {
Ok(data) => println!("You entered: {}", data),
Err(e) => eprintln!("Error: {}", e),
}