mcarton/rust-derivative

Feature request: Add a way to display only part of a collection-like type

dzfranklin opened this issue · 0 comments

I want to indicate in the debug representation that a field contains Vec or slice and give a preview of what sort of data it contains without showing the whole slice. I propose an option like so

#[derivative(Debug=take(10))]
field: Vec<u8>

which translates to whatever the debug formatting of the following is

field.iter().take(10).collect::Vec<_>()

I'm happy to make a PR if this is something you're open to.