oxidecomputer / oxidecomputer/omicron

Want types for representing non-empty collections

Open
#11,280 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
572
Forks
97
Avg merge
2d 12h
Merged PRs (30d)
96

Description

There are a lot of places where we use containers of various kinds, but where we also know the containers can't be empty. This came up on #11236 in this comment. That refers to types like this one:

https://github.com/oxidecomputer/omicron/blob/9d95e0cf4542d2bc776c40b69f97ba6e05cff199/sled-agent/types/versions/src/multiple_zone_external_ips/inventory.rs#L76-L79

We're checking in the various constructors and deserializers that the type can't be empty, something we'd like to continue to represent at the type level. That prevents needing to do things like container.iter().next().unwrap("this can't be empty") all over the place.

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 with sled-agent/types/versions/src/multiple_zone_external_ips/inventory.rs, especially the referenced type, and review the constructors and deserializers that currently verify non-emptiness. Determine the scope and design for representing non-empty collections at the type level; done means relevant callers no longer need repeated unwrap checks for an invariant already guaranteed by the type.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.