mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-11-08 09:09:17 +01:00
Add press_enter_prompt
This commit is contained in:
parent
52c0f5b39e
commit
2b7ac91505
11
src/main.rs
11
src/main.rs
@ -45,6 +45,11 @@ fn clear_terminal(stdout: &mut StdoutLock) -> io::Result<()> {
|
|||||||
stdout.write_all(b"\x1b[H\x1b[2J\x1b[3J")
|
stdout.write_all(b"\x1b[H\x1b[2J\x1b[3J")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn press_enter_prompt() -> io::Result<()> {
|
||||||
|
io::stdin().lock().read_until(b'\n', &mut Vec::new())?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// Rustlings is a collection of small exercises to get you used to writing and reading Rust code
|
/// Rustlings is a collection of small exercises to get you used to writing and reading Rust code
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(version)]
|
#[command(version)]
|
||||||
@ -98,7 +103,7 @@ fn main() -> Result<()> {
|
|||||||
let mut stdout = io::stdout().lock();
|
let mut stdout = io::stdout().lock();
|
||||||
stdout.write_all(b"This command will create the directory `rustlings/` which will contain the exercises.\nPress ENTER to continue ")?;
|
stdout.write_all(b"This command will create the directory `rustlings/` which will contain the exercises.\nPress ENTER to continue ")?;
|
||||||
stdout.flush()?;
|
stdout.flush()?;
|
||||||
io::stdin().lock().read_until(b'\n', &mut Vec::new())?;
|
press_enter_prompt()?;
|
||||||
stdout.write_all(b"\n")?;
|
stdout.write_all(b"\n")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,9 +139,7 @@ fn main() -> Result<()> {
|
|||||||
let welcome_message = welcome_message.trim();
|
let welcome_message = welcome_message.trim();
|
||||||
write!(stdout, "{welcome_message}\n\nPress ENTER to continue ")?;
|
write!(stdout, "{welcome_message}\n\nPress ENTER to continue ")?;
|
||||||
stdout.flush()?;
|
stdout.flush()?;
|
||||||
|
press_enter_prompt()?;
|
||||||
io::stdin().lock().read_until(b'\n', &mut Vec::new())?;
|
|
||||||
|
|
||||||
clear_terminal(&mut stdout)?;
|
clear_terminal(&mut stdout)?;
|
||||||
}
|
}
|
||||||
StateFileStatus::Read => (),
|
StateFileStatus::Read => (),
|
||||||
|
Loading…
Reference in New Issue
Block a user