Skip to content

Want types for representing non-empty collections #11280

Description

@bnaecker

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:

pub struct NexusExternalIps(
#[schemars(length(min = 1, max = "MAX_ZONE_EXTERNAL_IPS"))]
pub(crate) BTreeSet<IpAddr>,
);

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions