Stack traces in Rust

I'll admit it – I was missing those sweet stack traces from other languages. Fear not, Rust has your back (well, backtrace, technically...)

Here's the quick and dirty way to programmatically trigger a stack trbacktrace:

use std::backtrace::Backtrace;

fn main() {
    // print the stack trace if either RUST_BACKTRACE or RUST_LIB_BACKTRACE is set,
    // you know, if you're feeling polite
    println!("backtrace: {}", Backtrace::capture());

    // forget politeness, I NEED that backtrace!
    println!("backtrace: {}", Backtrace::force_capture());

Happy debugging! 🛠️