Function read_u32

Source
pub fn read_u32(msg: Option<&str>, err_msg: Option<&str>) -> u32
Expand description

§ARGUMENTS

‘msg’ (Option<&str>) - an optional message which will be printed at the same line as the input prompt. Must be set to Some(“…”) or None.

‘err_msg’ (Option<&str>) - an optional error message which will be printed if the user inputs an invalid value. Must be set to Some(“…”) or None.

§DESCRIPTION

Prompts the user to type an integer value (u32) which will then be returned. If user writes an invalid value, they will be prompted to try again.

Provides an information message on the same line as the prompt if Some(“…”) is provided, and just the prompt if None is provided.

If err_msg is set to None, a default message will be shown.

§RETURNS

An integer value of type u32 provided by the user.

§EXAMPLES

use quick_input::read_u32;
let user_u32_with_msg = read_u32(Some("Please input a number: "), Some("Please input a valid number."));

let user_u32: u32 = read_u32(None, None);