Skip to main content

read_and_mut

Function read_and_mut 

Source
pub fn read_and_mut<F>(
    color: &str,
    begin: &str,
    again: &str,
    f: F,
) -> Result<(), Error>
where F: FnMut(&mut Repline<'_, Stdin>, &str) -> Result<Response, Box<dyn Error>>,
Expand description

Implements a basic menu loop using an embedded Repline, provided to the caller’s closure, f.

Repeatedly runs the provided closure on the input strings, obeying the closure’s Response. The closure may modify the state of the Repline, including taking additional input.

Captures and displays all user Errors.

§Keybinds

  • Ctrl+C exits the loop
  • Ctrl+D clears the input, but runs the closure with the old input