oxidecomputer / oxidecomputer/hubris

want to derive `counters::Count` for structs when they have `count(children)`able enum fields

Open
#2,674 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

:wave: good first issue developer-experience
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 counters crate doesn't support deriving Count for a struct, even if it has count(Children) on a field that implements Count? 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.