Example:
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
#[serde(tag = "@tag")]
pub enum TaggedEnum {
VariantTag(WrappedVariant),
}
#[derive(Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct WrappedVariant {
pub variant: Variant,
}
#[derive(Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Variant {
#[serde(rename = "@float")]
pub float: f64,
}
fn main() {
let document = r#"
<?xml version="1.0" encoding="ISO-8859-1"?>
<variant float="0.0">
</variant>
"#;
let _: Variant = quick_xml::de::from_str(document).unwrap();
let document = r#"
<?xml version="1.0" encoding="ISO-8859-1"?>
<tagged_enum tag="VariantTag">
<variant float="0.0">
</variant>
</tagged_enum>
"#;
let _: TaggedEnum = quick_xml::de::from_str(document).unwrap();
}
Expected behaviour
Both documents are deserialized correctly without any errors.
Actual behaviour
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Custom("invalid type: string \"0.0\", expected f64")', src/main.rs:38:59
The parser seems to derail completely, any type that is not a String gives an error.
Example:
Expected behaviour
Both documents are deserialized correctly without any errors.
Actual behaviour
The parser seems to derail completely, any type that is not a String gives an error.