You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update: this example works on other people's systems, but fails on mine. My specs: - M1 Max Macbook Pro running macOS Sonoma 14.5 - rustc 1.76.0 Already tried after running cargo clean, same result.
The struct correctly serializes and deserializes back into the original, with no errors
Observed output
serialized: "{\"foo\":1.0}"
thread 'main' panicked at temp.rs:25:65:
called `Result::unwrap()` on an `Err` value: Error("invalid type: map, expected f64", line: 1, column: 11)
stack backtrace:
0: rust_begin_unwind
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
1: core::panicking::panic_fmt
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
2: core::result::unwrap_failed
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/result.rs:1649:5
3: core::result::Result<T,E>::unwrap
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/result.rs:1073:23
4: temp::main
at ./astra-server/examples/temp.rs:25:31
5: core::ops::function::FnOnce::call_once
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Notes
This only happens when the inner type contains a f64 or f32. String and integer types seem to ser/deser without an error. The error also goes away when I remove #[serde(flatten)]
The text was updated successfully, but these errors were encountered:
adityabaradwaj
changed the title
Flattened nested structs throw deserialize error when inner type contains a float
Flattened nested structs throw deserialize error "invalid type: map, expected f64" when inner type contains a float
May 27, 2024
See here for related issue: #2623. This is only reproducible within certain crate/workspace setups. Presumably some other dependencies are affecting serde's behavior
Update: this example works on other people's systems, but fails on mine.My specs:- M1 Max Macbook Pro running macOS Sonoma 14.5- rustc 1.76.0Already tried after runningcargo clean
, same result.Minimal reproducible example:
Expected output
The struct correctly serializes and deserializes back into the original, with no errors
Observed output
Notes
This only happens when the inner type contains a f64 or f32. String and integer types seem to ser/deser without an error. The error also goes away when I remove
#[serde(flatten)]
The text was updated successfully, but these errors were encountered: