Browse Source

feat: implement basic read-eval-print loop

main
fdai7381 2 years ago
committed by fdai7451
parent
commit
c8e44a6b26
  1. 33
      src/main.rs

33
src/main.rs

@ -1,3 +1,30 @@
fn main() {
println!("Hello, world!");
}
use rustyline::error::ReadlineError;
use rustyline::{Editor, Result};
fn main() -> Result<()> {
let mut rl = Editor::<()>::new()?;
loop {
let readline = rl.readline("» ");
match readline {
Ok(line) => {
println!("Line: {}", line);
},
Err(ReadlineError::Interrupted) => {
println!("CTRL-C");
break
},
Err(ReadlineError::Eof) => {
println!("CTRL-D");
break
},
Err(err) => {
println!("Error: {:?}", err);
break
}
}
}
Ok(())
}
Loading…
Cancel
Save