Ruby's binding.pry for Rust — drop pry!() in your code to pause execution and inspect variables in an interactive REPL ✒️
Rust
2
2 commits
updated Oct 9, 2026
An interactive REPL breakpoint for Rust, inspired by Ruby's binding.pry.
Drop a pry!() into your code and execution pauses with an interactive
prompt where you can inspect variables, view the surrounding source, and
print a backtrace — then continue running.
The prompt supports line editing and history (arrow keys, Ctrl-A/E/H,
etc.) via rustyline. The only dependency is rustyline, and even that can
be disabled with default-features = false for a std-only build.
binding.pry?Ruby is fully dynamic, so binding.pry can see every local variable
automatically. Rust is compiled and has no runtime reflection, so you tell
pry! which variables (or expressions) to capture. Anything that
implements Debug works.
[dependencies]
pry-rs = { git = "https://github.com/100010/pry-rs" }
use pry::pry;
#[derive(Debug)]
struct User {
name: String,
age: u32,
}
fn main() {
let user = User { name: "alice".into(), age: 30 };
let scores = [88, 92, 75];
pry!(user, scores, scores.len()); // ← execution pauses here
println!("resumed!");
}
Running this opens a prompt:
From: src/main.rs:13
...
=> 13: pry!(user, scores, scores.len());
...
Type "help" for commands, "continue" to resume.
pry> ls
user User = User { name: "alice", age: 30 }
scores [i32; 3] = [88, 92, 75]
scores.len() usize = 3
pry> p user
=> (User) User {
name: "alice",
age: 30,
}
pry> user.name
=> "alice"
pry> scores[1]
=> 92
pry> c
resumed!
| Command | Description |
|---|---|
ls | list captured variables |
<name> | print a variable ({:?}) |
<name>.field | access sub-fields: user.name, items[0].id, map["key"] |
p <name> | pretty-print ({:#?}), also works with paths |
whereami | show source around the breakpoint |
bt | show a backtrace |
continue, c | resume execution |
exit, quit | terminate the program |
help, h | show this help |
Debug output) at the moment pry! runs; the
REPL shows a snapshot, it cannot mutate your program's state.user.name, items[0]) works by parsing the captured
Debug text. Output from #[derive(Debug)] parses reliably; exotic
hand-written Debug impls may not.RUST_BACKTRACE=1.NO_COLOR is set.std::any::type_name_of_val).cargo run --example basic
MIT
Ruby's binding.pry for Rust — drop pry!() in your code to pause execution and inspect variables in an interactive REPL ✒️
Rust
2
2 commits
updated Oct 9, 2026
An interactive REPL breakpoint for Rust, inspired by Ruby's binding.pry.
Drop a pry!() into your code and execution pauses with an interactive
prompt where you can inspect variables, view the surrounding source, and
print a backtrace — then continue running.
The prompt supports line editing and history (arrow keys, Ctrl-A/E/H,
etc.) via rustyline. The only dependency is rustyline, and even that can
be disabled with default-features = false for a std-only build.
binding.pry?Ruby is fully dynamic, so binding.pry can see every local variable
automatically. Rust is compiled and has no runtime reflection, so you tell
pry! which variables (or expressions) to capture. Anything that
implements Debug works.
[dependencies]
pry-rs = { git = "https://github.com/100010/pry-rs" }
use pry::pry;
#[derive(Debug)]
struct User {
name: String,
age: u32,
}
fn main() {
let user = User { name: "alice".into(), age: 30 };
let scores = [88, 92, 75];
pry!(user, scores, scores.len()); // ← execution pauses here
println!("resumed!");
}
Running this opens a prompt:
From: src/main.rs:13
...
=> 13: pry!(user, scores, scores.len());
...
Type "help" for commands, "continue" to resume.
pry> ls
user User = User { name: "alice", age: 30 }
scores [i32; 3] = [88, 92, 75]
scores.len() usize = 3
pry> p user
=> (User) User {
name: "alice",
age: 30,
}
pry> user.name
=> "alice"
pry> scores[1]
=> 92
pry> c
resumed!
| Command | Description |
|---|---|
ls | list captured variables |
<name> | print a variable ({:?}) |
<name>.field | access sub-fields: user.name, items[0].id, map["key"] |
p <name> | pretty-print ({:#?}), also works with paths |
whereami | show source around the breakpoint |
bt | show a backtrace |
continue, c | resume execution |
exit, quit | terminate the program |
help, h | show this help |
Debug output) at the moment pry! runs; the
REPL shows a snapshot, it cannot mutate your program's state.user.name, items[0]) works by parsing the captured
Debug text. Output from #[derive(Debug)] parses reliably; exotic
hand-written Debug impls may not.RUST_BACKTRACE=1.NO_COLOR is set.std::any::type_name_of_val).cargo run --example basic
MIT