Skip to content

integer in the range [1..32] is represented as a NonZeroU64 #975

Description

@ahl
{
  "$defs": {
    "MaxPathConfig": {
      "type": "integer",
      "maximum": 32,
      "minimum": 1
    }
  }
}

Turns into

#[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct MaxPathConfig(pub ::std::num::NonZeroU64);
impl ::std::ops::Deref for MaxPathConfig {
    type Target = ::std::num::NonZeroU64;
    fn deref(&self) -> &::std::num::NonZeroU64 {
        &self.0
    }
}

That's fine but I'd prefer to see something like this:

pub struct MaxPathConfig(u8)

impl TryFrom<u8> for MaxPathConfig {
    // ...
}

Activity

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

Metadata

Metadata

Assignees

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