| Crates.io | system-pause |
| lib.rs | system-pause |
| version | 0.1.2 |
| created_at | 2025-01-22 16:39:27.661919+00 |
| updated_at | 2025-02-21 05:04:33.694748+00 |
| description | `system-pause` is a Rust library for stopping program execution temporarily. It offers simple macros for pausing the console, either waiting for user input or pausing with a countdown timer. This is useful for debugging or interactive console applications. |
| homepage | |
| repository | https://github.com/Drew-Chase/system-pause.git |
| max_upload_size | |
| id | 1526829 |
| size | 77,296 |
system-pause is a Rust library for stopping program execution temporarily. It offers simple macros for pausing the console, either waiting for user input or pausing with a countdown timer. This is useful for debugging or interactive console applications.
Add system-pause to your Cargo.toml as follows:
[dependencies]
system-pause = "0.1.2" # Or what ever the latest version is.
or install via github
[dependencies]
system-pause = {git="https://github.com/Drew-Chase/system-pause.git"}
Then, include it in your Rust code using:
use system_pause::{pause, pause_for_time};
pause!()Pauses the program and displays a default message: "Press Enter to continue...".
use system_pause::pause;
fn main() {
println!("Pausing...");
pause!(); // Waits for user to press Enter
println!("Continuing...");
}
Console output
> Pausing...
> Press Enter to continue...
> Continuing...
You can also specify a custom message:
use system_pause::pause;
fn main() {
println!("Custom pause!");
pause!("Please press Enter to proceed..."); // Custom message
println!("Resumed.");
}
Console output
> Custom pause!
> Please press Enter to proceed...
> Resumed.
pause_for_time!(<seconds>)Pauses the program for a given number of seconds and provides a real-time countdown on the console.
Note: This macro blocks the current thread while waiting. Use this carefully in applications that require thread responsiveness or real-time performance.
use system_pause::pause_for_time;
fn main() {
println!("Timer pause!");
pause_for_time!(5, "This line should be cleared after {} seconds."); // Pauses for 5 seconds
println!("5 seconds have passed.");
}
Console output

Basic Example:
use system_pause::pause;
fn main() {
println!("Hello, world!");
pause!();
println!("Goodbye, world!");
}
Custom Message Example:
use system_pause::pause;
fn main() {
println!("Hello, world!");
pause!("Please press Enter to continue...");
println!("Goodbye, world!");
}
Timer-based Pause Example:
use system_pause::pause_for_time;
fn main() {
println!("Hello, world!");
pause_for_time!(3); // Pauses for 3 seconds with a countdown
println!("Goodbye, world!");
}
For more information please see the examples directory
pause_for_time! macro, note that it blocks the current thread while waiting. This may cause performance issues in applications running multiple threads or handling time-sensitive tasks.This project is licensed under the GPL-3.0 License. See the LICENSE file for details.