| Crates.io | print-break |
| lib.rs | print-break |
| version | 0.2.2 |
| created_at | 2025-12-31 01:59:21.49169+00 |
| updated_at | 2025-12-31 04:59:09.409459+00 |
| description | A simple debugging macro that pretty-prints variables and pauses execution |
| homepage | |
| repository | https://github.com/babinc/print-break |
| max_upload_size | |
| id | 2013748 |
| size | 65,271 |
A simple Rust debugging macro that pretty-prints variables and pauses execution. No debugger needed.
Debug type with syntax highlightingPRINT_BREAK=0t to see how you got therec to copy valuesprint_break_if![dependencies]
print-break = "0.1"
use print_break::{print_break, print_break_if};
fn main() {
let user_id = 42;
let name = "ferris";
let items = vec![1, 2, 3];
// Basic breakpoint
print_break!(user_id, name, items);
// Conditional breakpoint (great for loops)
for i in 0..100 {
print_break_if!(i == 50, i);
}
// JSON strings are auto-formatted
let json = r#"{"status": "ok", "data": [1, 2, 3]}"#;
print_break!(json);
}
┌─ BREAK #1 ─────────────────────────────────────
│ src/main.rs:8 │
├────────────────────────────────────────────────
│ user_id = 42
│ name = "ferris"
│ items = [1, 2, 3]
└────────────────────────────────────────────────
[Enter=continue, m=more, s=skip all, q=quit]
When paused at a breakpoint:
| Key | Action |
|---|---|
| Enter | Continue to next breakpoint |
| m | Show full output (if truncated) |
| t | Show stack trace |
| c | Copy value to clipboard |
| s | Skip all remaining breakpoints |
| q | Quit the program |
| h / ? | Show help |
# Disable all breakpoints
PRINT_BREAK=0 cargo run
# Re-enable (default)
PRINT_BREAK=1 cargo run
# Set max nesting depth for structs (default: 4)
PRINT_BREAK_DEPTH=6 cargo run
# Show all nesting (no collapse)
PRINT_BREAK_DEPTH=999 cargo run
# Border styles: rounded (default), sharp, double, ascii
PRINT_BREAK_STYLE=double cargo run
PRINT_BREAK_STYLE=ascii cargo run
When stderr is not a TTY (piped to file, running in CI), print-break automatically:
Perfect for debugging loops:
use print_break::print_break_if;
for i in 0..1000 {
// Only break when i is 500
print_break_if!(i == 500, i);
// Break when condition is met
print_break_if!(some_value > threshold, some_value, threshold);
}
In release builds (cargo build --release), all print_break! and print_break_if! calls compile to nothing - zero runtime overhead.
Strings are automatically detected and pretty-printed:
Long output is truncated at 50 lines. Press m to see the full output.
Copy editors/nvim/print-break.lua to your Neovim config:
cp editors/nvim/print-break.lua ~/.config/nvim/after/plugin/
Keybindings (Rust files only):
| Key | Mode | Action |
|---|---|---|
<leader>pb |
Normal | Insert print_break!() with word under cursor |
<leader>pb |
Visual | Wrap selection in print_break!() |
<leader>pB |
Normal | Insert print_break_if!(condition, vars) |
<leader>pc |
Normal | Remove all print_break! from current buffer |
<leader>pC |
Normal | Remove all print_break! from all Rust files |
Smart features:
print_break! if one exists on the next lineMIT