Skip to main content

ReplHandler

Trait ReplHandler 

Source
pub trait ReplHandler {
    // Required methods
    fn prompt(&self, is_continuation: bool) -> &str;
    fn is_complete(&self, code: &str) -> bool;
    fn handle_line(&mut self, line: &str) -> Result<HandleResult, ReplError>;

    // Provided methods
    fn highlight<'a>(&self, _code: &'a str) -> Option<HighlightResult<'a>> { ... }
    fn get_indent(&self, _code: &str) -> usize { ... }
}
Expand description

语言集成接口

Required Methods§

Source

fn prompt(&self, is_continuation: bool) -> &str

提示符

Source

fn is_complete(&self, code: &str) -> bool

检查输入是否已完整(例如括号是否闭合) 如果返回 false,REPL 将进入多行输入模式

Source

fn handle_line(&mut self, line: &str) -> Result<HandleResult, ReplError>

执行代码行

Provided Methods§

Source

fn highlight<'a>(&self, _code: &'a str) -> Option<HighlightResult<'a>>

获取语法高亮结果

Source

fn get_indent(&self, _code: &str) -> usize

获取当前缩进级别

Implementors§