use std::io::{self, Write}; fn calc_age(age: u16) -> u16 { const DAYS_IN_YEAR: u16 = 365; return age * DAYS_IN_YEAR; } fn main() { print!("Write your age: "); io::stdout().flush().expect("Failed to flush stdout."); let mut buffer = String::new(); io::stdin() .read_line(&mut buffer) .expect("Error while trying to read from stdin."); let age: u16 = buffer.trim().parse() .expect("The input is not an integer between 0 and 65535"); let days = calc_age(age); println!("Your age is about {} days", days); }