Skip to content

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

@ahl

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 {
    // ...
}

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