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§
Sourcefn is_complete(&self, code: &str) -> bool
fn is_complete(&self, code: &str) -> bool
检查输入是否已完整(例如括号是否闭合) 如果返回 false,REPL 将进入多行输入模式
Sourcefn handle_line(&mut self, line: &str) -> Result<HandleResult, ReplError>
fn handle_line(&mut self, line: &str) -> Result<HandleResult, ReplError>
执行代码行
Provided Methods§
Sourcefn highlight<'a>(&self, _code: &'a str) -> Option<HighlightResult<'a>>
fn highlight<'a>(&self, _code: &'a str) -> Option<HighlightResult<'a>>
获取语法高亮结果
Sourcefn get_indent(&self, _code: &str) -> usize
fn get_indent(&self, _code: &str) -> usize
获取当前缩进级别