Crate input_validation

source ·
Expand description

Prompts the user for input and parses the input as a value of type ‘T’.

If the input cannot be parsed as the request ‘T’, the function will prompt the user again until a valid input is entered.

Arguments

  • ‘prompt’ - A string that will be printed to the console to prompt the user for input.

Returns

A value of type ‘T’ that was parsed from the user’s input.

Panics

This function will panic if ‘T’ does not implement the ‘FromStr’ trait.

Functions

  • Prompts the user for a boolean input, returning true if the input is “y” or “yes” (case insensitive), and false if the input is “n” or “no” (case insensitive). If the input does not match either “y”, “yes”, “n”, or “no”, the function will loop and prompt the user again.
  • Prompts the user to select a choice from a list of options and returns the index of the selected choice.
  • Prompts the user to enter an email address and returns it as a string.
  • Prompts the user for input and parses the user’s response as a specified type.
  • Reads input from the user and returns a vector of elements of type T.