serde support broken ?
GeorgeKT opened this issue · comments
I enable the use_serde features in my Cargo.toml:
[package]
name = "uom-serde"
version = "0.1.0"
edition = "2021"[dependencies]
ron = "0.8"
serde = { version = "1", features = ["derive"] }
uom = { version = "0.33.0", features = ["use_serde"] }
The following sample application fails to build:
use serde::{Deserialize, Serialize};
use uom::si::length::meter;#[derive(Debug, Deserialize, Serialize)]
struct MyStruct {
boolean: bool,
float: f32,
foo: meter,
}fn main() {
let x: MyStruct = ron::from_str("(boolean: true, float: 1.23)").unwrap();
println!("RON: {}", ron::to_string(&x).unwrap());
}
Output:
error[E0277]: the trait bound
uom::si::length::meter: Deserialize<'_>
is not satisfied
--> src/main.rs:8:10
|
8 | foo: meter,
| ^^^^^ the traitDeserialize<'_>
is not implemented foruom::si::length::meter
|
= help: the following other types implement traitDeserialize<'de>
:
&'a Path
&'a [u8]
&'a str
()
(T0, T1)
(T0, T1, T2)
(T0, T1, T2, T3)
(T0, T1, T2, T3, T4)
and 132 others
note: required by a bound innext_element
--> /home/joris/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.152/src/de/mod.rs:1729:12
|
1729 | T: Deserialize<'de>,
| ^^^^^^^^^^^^^^^^ required by this bound innext_element
...
Am I doing something wrong, or is this feature just broken ?
You need to use the quantity Length
, meter
is just a unit.