Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infer unsigned integers #10

Open
clux opened this issue Nov 28, 2021 · 0 comments
Open

infer unsigned integers #10

clux opened this issue Nov 28, 2021 · 0 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@clux
Copy link
Member

clux commented Nov 28, 2021

Currently the kubernetes schemas only mention support int32 or int64 integer types, but the schemas contain a minimum: f64 where the minimum is set to 0.0 in unsigned cases.

We could maybe check for it and turn the signed ints into unsigneds at that point:

"int32" => {
    match value.minimum {
        Some(0.0) => "u32".to_string(),
        _ => "i32".to_string(),
}

but that's illegal in the future:

warning: floating-point types cannot be used in patterns
   --> src/main.rs:384:26
    |
384 |                     Some(0.0) => "u32".to_string(),
    |                          ^^^
    |
    = note: `#[warn(illegal_floating_point_literal_pattern)]` on by default
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620

Could maybe do this by looking at it pre-deserialization to compare against "0.0". But that is if it is even a sane thing to do. Input welcome.

Note that this is only a problem when coming from go; schemars will emit rust's full int range, and we will handle them if set explicitly.

@clux clux added help wanted Extra attention is needed question Further information is requested labels Nov 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant