fix erroneous debug assertion in nested namespace case
The assertion was checking to ensure that the emitted tag had no prefix, which breaks the case where a prefix is required, but only in debug builds!
This commit is contained in:
parent
05de91af02
commit
3e72aa7ae3
|
@ -228,7 +228,6 @@ fn serialize_struct(
|
|||
) -> Result<(), instant_xml::Error> {
|
||||
// Start tag
|
||||
let prefix = serializer.write_start(#tag, #default_namespace)?;
|
||||
debug_assert_eq!(prefix, None);
|
||||
|
||||
// Set up element context, this will also emit namespace declarations
|
||||
#context
|
||||
|
|
|
@ -47,3 +47,34 @@ fn struct_child_namespaces() {
|
|||
"<StructChildNamespaces xmlns=\"URI\" xmlns:bar=\"BAZ\" xmlns:foo=\"BAR\"><NestedDifferentNamespace xmlns=\"\" xmlns:internal=\"INTERNAL\"><internal:flag_internal_prefix>false</internal:flag_internal_prefix></NestedDifferentNamespace><Nested xmlns:internal=\"INTERNAL\"><bar:flag_parent_prefix>true</bar:flag_parent_prefix><internal:flag_internal_prefix>false</internal:flag_internal_prefix></Nested></StructChildNamespaces>"
|
||||
);
|
||||
}
|
||||
|
||||
#[derive(Debug, ToXml)]
|
||||
#[xml(rename = "DIDL-Lite", ns("DIDL", upnp = "UPNP"))]
|
||||
pub struct DidlLite {
|
||||
pub item: UpnpItem,
|
||||
}
|
||||
|
||||
#[derive(Debug, ToXml)]
|
||||
#[xml(rename = "item", ns("DIDL"))]
|
||||
pub struct UpnpItem {
|
||||
pub album_art: Option<AlbumArtUri>,
|
||||
}
|
||||
|
||||
#[derive(Debug, ToXml)]
|
||||
#[xml(rename = "albumArtURI", ns("UPNP", upnp = "UPNP"))]
|
||||
pub struct AlbumArtUri {
|
||||
#[xml(direct)]
|
||||
pub uri: String,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_didl() {
|
||||
let didl = DidlLite {
|
||||
item: UpnpItem {
|
||||
album_art: Some(AlbumArtUri {
|
||||
uri: "http://art".to_string(),
|
||||
}),
|
||||
},
|
||||
};
|
||||
assert_eq!(to_string(&didl).unwrap(), "<DIDL-Lite xmlns=\"DIDL\" xmlns:upnp=\"UPNP\"><item><upnp:albumArtURI>http://art</upnp:albumArtURI></item></DIDL-Lite>");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue