fmt_to_string/fmt_to_string.rs
1use color_backtrace::BacktracePrinter;
2
3fn main() -> Result<(), std::io::Error> {
4 let trace = backtrace::Backtrace::new();
5 let printer = BacktracePrinter::default();
6 let str = printer.format_trace_to_string(&trace)?;
7
8 if cfg!(windows) {
9 println!(
10 "Warning: on Windows, you'll have to enable VT100 \
11 printing for your app in order for this to work \
12 correctly. This example doesn't do this."
13 );
14 }
15
16 println!("{}", str);
17
18 Ok(())
19}