rust-derivative
rust-derivative copied to clipboard
Improve `Debug` derive with `[u8]`/`str`
This:
#[derive(Debug)]
struct Foo {
data: Vec<u8>,
}
will always print all vector in a very noisy form. Some filters could be nice:
- Print shorter version of the data (remove end/remove middle part):
Foo { data: [12, 102, 111, 111, 12, …] }orFoo { data: [12, 102, 111, …, 98, 97, 122] }. - Print as ascii/UTF-8 when possible:
Foo { data: [12, "foo", 12, "bar", 12, "baz"] }.
I would personally like a version where it renders like a bytestring, for example like Foo { data: b"\x01foo bar" }.