rust-derivative icon indicating copy to clipboard operation
rust-derivative copied to clipboard

Improve `Debug` derive with `[u8]`/`str`

Open mcarton opened this issue 7 years ago • 1 comments

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, …] } or Foo { data: [12, 102, 111, …, 98, 97, 122] }.
  • Print as ascii/UTF-8 when possible: Foo { data: [12, "foo", 12, "bar", 12, "baz"] }.

mcarton avatar Nov 07 '18 19:11 mcarton

I would personally like a version where it renders like a bytestring, for example like Foo { data: b"\x01foo bar" }.

auscompgeek avatar Jul 14 '19 12:07 auscompgeek