diff --git a/src/reader.rs b/src/reader.rs index e16055d..d545ff3 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -1108,7 +1108,7 @@ where break; } } - Event::Comment(_) => {} + Event::Comment(_) | Event::Empty(_) => {} _ => break, } } @@ -1772,6 +1772,44 @@ mod tests { ); } + #[test] + fn test_parse_placemark_children_with_empty_field() { + let kml_str = r#" + + Test Placemark + + CustomValue + + CustomValue2 + + + "#; + let f: Kml = kml_str.parse().unwrap(); + assert_eq!( + f, + Kml::Placemark(Placemark { + name: Some("Test Placemark".to_string()), + children: vec![Element { + name: "ExtendedData".to_string(), + children: vec![ + Element { + name: "CustomField".to_string(), + content: Some("CustomValue".to_string()), + ..Default::default() + }, + Element { + name: "AnotherCustomField".to_string(), + content: Some("CustomValue2".to_string()), + ..Default::default() + } + ], + ..Default::default() + }], + ..Default::default() + }) + ); + } + #[test] fn test_parse_doc_with_sibling_folders() { let kml_str = r#" diff --git a/src/types/vec2.rs b/src/types/vec2.rs index dd9e41f..a81012c 100644 --- a/src/types/vec2.rs +++ b/src/types/vec2.rs @@ -22,19 +22,14 @@ impl Default for Vec2 { } } -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq, Default)] pub enum Units { + #[default] Fraction, Pixels, InsetPixels, } -impl Default for Units { - fn default() -> Self { - Self::Fraction - } -} - impl FromStr for Units { type Err = Error;