inspect: clean up field formatting #1331
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Make a field's formatting (currently hex, binary, and counter) easier to define. Instead of requiring the formatting to be specified on exactly the value to be formatted, specify it at any part of the node hierarchy, and inherit it on all child fields.
This and some other cleanups makes it possible to do a few things:
You can specify
hex
on the derive of an entire struct in order to avoid having to specify it on each field.You can specify
hex
on fields that already have awith
oriter_by_index
, to avoid needing to manually applyAsHex
in a.map
call.You can specify
hex
on arbitrarily complicated numeric fields such asArc<RwLock<AtomicU32>>
, without needing explicitInspect
impls forAsHex<T>
.As part of this, simplify a bunch of inspect derives.