-
Notifications
You must be signed in to change notification settings - Fork 217
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
Deserializing into a type with an unsigned integer doesn't give the expected result #93
Comments
Additionally, related to this is that values greater than |
Closed
kesyog
added a commit
to kesyog/config-rs
that referenced
this issue
Jun 28, 2022
* Attempt to convert between integer types using `TryInto`-based conversions rather than blanket failing for some source and destination types. * Use `into_uint` instead of `into_int` in `Value` Deserialize implementations for unsigned integer types. Previously, we were converting from signed types to unsigned types using `as`, which can lead to surprise integer values conversions (rust-cli#93). Fixes rust-cli#352 and rust-cli#93
Updated example: use config::Config;
use serde::Deserialize;
#[derive(Deserialize)]
struct Foo {
bar: u64,
}
fn main() {
let settings = Config::builder()
.add_source(config::File::with_name("test"))
.build()
.unwrap();
let foo: Foo = settings.try_deserialize().unwrap();
println!("{}", foo.bar);
} |
kesyog
added a commit
to kesyog/config-rs
that referenced
this issue
Jun 29, 2022
* Attempt to convert between integer types using `TryInto`-based conversions rather than blanket failing for some source and destination types. * Use `into_uint` instead of `into_int` in `Value` Deserialize implementations for unsigned integer types. Previously, we were converting from signed types to unsigned types using `as`, which can lead to surprise integer values conversions (rust-cli#93). Fixes rust-cli#352 and rust-cli#93
Fixed on |
matthiasbeyer
pushed a commit
to matthiasbeyer/config-rs
that referenced
this issue
Aug 2, 2022
* Attempt to convert between integer types using `TryInto`-based conversions rather than blanket failing for some source and destination types. * Use `into_uint` instead of `into_int` in `Value` Deserialize implementations for unsigned integer types. Previously, we were converting from signed types to unsigned types using `as`, which can lead to surprise integer values conversions (rust-cli#93). Fixes rust-cli#352 and rust-cli#93 (cherry picked from commit 7db2e8b)
matthiasbeyer
pushed a commit
that referenced
this issue
Aug 2, 2022
* Attempt to convert between integer types using `TryInto`-based conversions rather than blanket failing for some source and destination types. * Use `into_uint` instead of `into_int` in `Value` Deserialize implementations for unsigned integer types. Previously, we were converting from signed types to unsigned types using `as`, which can lead to surprise integer values conversions (#93). Fixes #352 and #93 (cherry picked from commit 7db2e8b) Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Minimal example:
main.rs
test.toml
Running this code produces
18446744073709551615
instead of erroring that the value was outside of the range ofu64
The text was updated successfully, but these errors were encountered: