Skip to main content

LineHandler

Trait LineHandler 

Source
pub trait LineHandler {
    // Required method
    fn handle_line(&self, line: &str) -> Result<LoopAction, String>;
}
Expand description

Trait for handling lines read by [LineReader].

Implement this to inject command-execution logic into the REPL loop.

§Return values

  • Ok(LoopAction::Continue) — prompt for the next line.
  • Ok(LoopAction::Break) — exit the loop normally.
  • Err(msg) — print the error and continue.

Required Methods§

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<F> LineHandler for F
where F: Fn(&str) -> Result<LoopAction, String>,