compilation failure when mixing default
with NonZeroU8
#390
Labels
compile-fail
generated code doesn't compile
default
with NonZeroU8
#390
A schema like this...
... turns into code like this...
Which is as-intended:
defaults::default_u64
is intended to produce the default value that we want.However!
The
NonZero*
types implementTryFrom
for their corresponding primitive type, but not other primitive types. This appears to be a point of principle: rust-lang/rust#72712 (comment)So: cute as this would be, we need a different approach. Some options:
TryFrom
but has more implementations. This might be kind of annoying because we'd probably dump all this code into themod defaults
by default (no pun intended).default_non_zero_u64
... it would only create a little bit of annoying code to determine which one to use.default_u64
with two types (rather than one) i.e. the output type and an "intermediate type":defaults::default_u64::<NonZeroU8, u8>
The text was updated successfully, but these errors were encountered: