mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 05:52:19 +00:00
rustical_xml: Use darling for proc-macro parsing
This commit is contained in:
@@ -62,8 +62,9 @@ fn test_struct_document() {
|
||||
#[test]
|
||||
fn test_struct_rename_field() {
|
||||
#[derive(Debug, XmlDeserialize, PartialEq)]
|
||||
#[xml(root = b"document")]
|
||||
struct Document {
|
||||
#[xml(rename = "ok-wow")]
|
||||
#[xml(rename = b"ok-wow")]
|
||||
child: Child,
|
||||
}
|
||||
|
||||
@@ -73,12 +74,6 @@ fn test_struct_rename_field() {
|
||||
text: String,
|
||||
}
|
||||
|
||||
impl XmlRoot for Document {
|
||||
fn root_tag() -> &'static [u8] {
|
||||
b"document"
|
||||
}
|
||||
}
|
||||
|
||||
let doc = Document::parse_str(r#"<document><ok-wow>Hello!</ok-wow></document>"#).unwrap();
|
||||
assert_eq!(
|
||||
doc,
|
||||
@@ -93,17 +88,12 @@ fn test_struct_rename_field() {
|
||||
#[test]
|
||||
fn test_struct_optional_field() {
|
||||
#[derive(Debug, XmlDeserialize, PartialEq)]
|
||||
#[xml(root = b"document")]
|
||||
struct Document {
|
||||
#[xml(default = "Default::default")]
|
||||
child: Option<Child>,
|
||||
}
|
||||
|
||||
impl XmlRoot for Document {
|
||||
fn root_tag() -> &'static [u8] {
|
||||
b"document"
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, XmlDeserialize, PartialEq, Default)]
|
||||
struct Child;
|
||||
|
||||
@@ -119,7 +109,7 @@ fn test_struct_vec() {
|
||||
#[derive(Debug, XmlDeserialize, PartialEq)]
|
||||
#[xml(root = b"document")]
|
||||
struct Document {
|
||||
#[xml(rename = "child", flatten)]
|
||||
#[xml(rename = b"child", flatten)]
|
||||
children: Vec<Child>,
|
||||
}
|
||||
|
||||
@@ -147,7 +137,7 @@ fn test_struct_set() {
|
||||
#[derive(Debug, XmlDeserialize, PartialEq)]
|
||||
#[xml(root = b"document")]
|
||||
struct Document {
|
||||
#[xml(rename = "child", flatten)]
|
||||
#[xml(rename = b"child", flatten)]
|
||||
children: HashSet<Child>,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user