Function repline::prebaked::read_and

source ·
pub fn read_and<F>(
    color: &str,
    begin: &str,
    again: &str,
    f: F
) -> Result<(), Error>
where F: FnMut(&str) -> Result<Response, Box<dyn Error>>,
Expand description

Implements a basic menu loop using an embedded Repline.

Repeatedly runs the provided closure on the input strings, obeying the closure’s Response.

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