Skip to content

inspect: clean up field formatting #1331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 12, 2025
Merged

Conversation

jstarks
Copy link
Member

@jstarks jstarks commented May 10, 2025

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 a with or iter_by_index, to avoid needing to manually apply AsHex in a .map call.

  • You can specify hex on arbitrarily complicated numeric fields such as Arc<RwLock<AtomicU32>>, without needing explicit Inspect impls for AsHex<T>.

As part of this, simplify a bunch of inspect derives.

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 a `with` or
  `iter_by_index`, to avoid needing to manually apply `AsHex` in a
  `.map` call.

* You can specify `hex` on arbitrarily complicated numeric fields such
  as `Arc<RwLock<AtomicU32>>`, without needing explicit `Inspect` impls
  for `AsHex<T>`.

As part of this, simplify a bunch of inspect derives.
@jstarks jstarks requested review from a team as code owners May 10, 2025 22:06
@jstarks jstarks merged commit cb71499 into microsoft:main May 12, 2025
28 checks passed
@jstarks jstarks deleted the inspect_hex branch May 12, 2025 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants