oxidecomputer / oxidecomputer/hubris
want to derive `counters::Count` for structs when they have `count(children)`able enum fields
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.6k
- Forks
- 239
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 23
Description
See this comment I left on #2668 after I saw @jamesmunns hand-implementing Count for a struct because it was a struct:
Oh, huh, I think this is necessary because the
counterscrate doesn't support derivingCountfor a struct, even if it hascount(Children)on a field that implementsCount? It could be worth adding that to better support cases like this (not in this PR, I'll go make a ticket).Originally posted by @hawkw in https://github.com/oxidecomputer/hubris/pull/2668#discussion_r3938035867
At a first glance this didn't really seem worth having a derive that worked on structs because what would you count about them, but sometimes they have child fields that are countable, and it's nicer to not have to hand write that.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the counters::Count derive implementation and how it handles count(Children) on enum fields. Compare that behavior with the hand-written Count implementation discussed in pull request #2668. Done means structs containing countable child fields can derive Count without a manual implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- embedded-iot
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 62/100