Closed linsyking closed 9 months ago
use rustyline::{Config, DefaultEditor, Result};
use std::io::stdout;
use std::io::Write;
fn main() -> Result<()> {
let config = Config::builder()
.check_cursor_position(true)
.build();
let mut rl = DefaultEditor::with_config(config)?;
print!("hi");
stdout().flush()?;
let _ = rl.readline("> ")?;
Ok(())
}
I was writing a unix shell and sometimes it needs to print a string without newline so I need to flush the stdout buffer.
stdout().flush().unwrap();
should print stdout buffer "hi", but when I addreadline
, nothing prints out.