Expand description
Syntax aware debug printing.
Makes use of syn and prettyplease in order to provide the most
canonincal rust debug lines as possible, quickly.
Example usage
use dbg_pls::{pretty, DebugPls};
#[derive(DebugPls, Copy, Clone)]
pub struct Demo {
foo: i32,
bar: &'static str,
}
let mut val = [Demo { foo: 5, bar: "hello" }; 10];
val[6].bar = "Hello, world! I am a very long string";
let output = format!("{}", pretty(&val));
let expected = r#"[
Demo { foo: 5, bar: "hello" },
Demo { foo: 5, bar: "hello" },
Demo { foo: 5, bar: "hello" },
Demo { foo: 5, bar: "hello" },
Demo { foo: 5, bar: "hello" },
Demo { foo: 5, bar: "hello" },
Demo {
foo: 5,
bar: "Hello, world! I am a very long string",
},
Demo { foo: 5, bar: "hello" },
Demo { foo: 5, bar: "hello" },
Demo { foo: 5, bar: "hello" },
]"#;
assert_eq!(output, expected);Example with highlighting
use dbg_pls::{color, DebugPls};
#[derive(DebugPls, Copy, Clone)]
pub struct Demo {
foo: i32,
bar: &'static str,
}
let mut val = [Demo { foo: 5, bar: "hello" }; 10];
val[6].bar = "Hello, world! I am a very long string";
println!("{}", color(&val));Outputs:

How it works
All DebugPls implementations are forced to output only valid
syn::Expr values. These are then formatted using prettyplease::unparse.
Finally,
Macros
Structs
A helper designed to assist with creation of
DebugPls implementations for list-like structures.
A helper designed to assist with creation of
DebugPls implementations for structs.
A helper designed to assist with creation of
DebugPls implementations for tuples.
A helper designed to assist with creation of
DebugPls implementations for tuple structs.
Traits
Syntax aware pretty-printed debug formatting.
Functions
colorsWraps a Debug type into a std::fmt::Debug type for use in regular format!
prettyWraps a Debug type into a std::fmt::Debug type for use in regular format!
Derive Macros
deriveDerives the standard DebugPls implementation.