Function brane_shr::input::input_map

source ·
pub fn input_map<K, V, VA>(
    key_what: impl Display,
    val_what: impl Display,
    prompt: impl ToString,
    second_prompt: impl ToString,
    split: impl AsRef<str>,
    validator: Option<VA>,
    history: Option<impl History<String>>,
) -> Result<HashMap<K, V>, Error>
where K: Eq + FromStr + Hash, V: FromStr, K::Err: Error, V::Err: Error, VA: InputValidator<String>, VA::Err: ToString,
Expand description

Prompts the user for a map of arbitrary size.

The user can specify keys multiple times to overwrite previous ones.

§Arguments

  • key_what: Some string description to show to the user that tells them what kind of key they are inputting. Should fill in: Invalid .... Only used in the case they fail the first time.
  • val_what: Some string description to show to the user that tells them what kind of value they are inputting. Should fill in: Invalid .... Only used in the case they fail the first time.
  • prompt: The prompt to display to the user. You can use %I to get the current prompt index.
  • second_prompt: Another prompt to show for entries beyond the first. You can use %I to get the current prompt index.
  • split: The split sequence between keys and values.
  • validator: A validator that implements the dialoguer::InputValidator trait, or None if it is not possible. You can use the NoValidator concrete type when using no validator like so None::<NoValidator>
  • history: An optional History-capabable struct that can be used to keep track of this prompt’s history.

§Returns

A new HashMap that contains the user’s entered values.

§Errors

This function errors if we failed to interact with the user.