1
0
mirror of https://github.com/rust-lang/rustlings.git synced 2025-11-29 22:47:43 +02:00

Allow initialization in a workspace

This commit is contained in:
mo8it
2024-08-08 02:45:18 +02:00
parent 39580381fa
commit 8df66f7991
3 changed files with 66 additions and 43 deletions

12
src/term.rs Normal file
View File

@@ -0,0 +1,12 @@
use std::io::{self, BufRead, StdoutLock, Write};
pub fn clear_terminal(stdout: &mut StdoutLock) -> io::Result<()> {
stdout.write_all(b"\x1b[H\x1b[2J\x1b[3J")
}
pub fn press_enter_prompt(stdout: &mut StdoutLock) -> io::Result<()> {
stdout.flush()?;
io::stdin().lock().read_until(b'\n', &mut Vec::new())?;
stdout.write_all(b"\n")?;
Ok(())
}