Add support for comments
This commit is contained in:
parent
a199cc7b5c
commit
c584137ee5
|
@ -353,6 +353,7 @@ impl<'xml> Iterator for Context<'xml> {
|
|||
false => return Some(Err(Error::UnexpectedToken(format!("{token:?}")))),
|
||||
true => {}
|
||||
},
|
||||
Ok(Token::Comment { .. }) => continue,
|
||||
Ok(token) => return Some(Err(Error::UnexpectedToken(format!("{token:?}")))),
|
||||
Err(e) => return Some(Err(Error::Parse(e))),
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ use similar_asserts::assert_eq;
|
|||
|
||||
use instant_xml::{from_str, to_string, FromXml, ToXml};
|
||||
|
||||
#[derive(Debug, Eq, FromXml, PartialEq, ToXml)]
|
||||
#[derive(Clone, Debug, Eq, FromXml, PartialEq, ToXml)]
|
||||
struct Foo {
|
||||
#[xml(attribute)]
|
||||
flag: bool,
|
||||
|
@ -19,5 +19,14 @@ fn direct() {
|
|||
let xml = "<Foo flag=\"true\">cbdté</Foo>";
|
||||
|
||||
assert_eq!(to_string(&v).unwrap(), xml);
|
||||
assert_eq!(from_str::<Foo>(xml), Ok(v.clone()));
|
||||
|
||||
let xml = "<Foo flag=\"true\"><!--comment-->cbdté</Foo>";
|
||||
assert_eq!(from_str::<Foo>(xml), Ok(v.clone()));
|
||||
|
||||
let xml = "<Foo flag=\"true\"><!--comment--><!--comment-->cbdté</Foo>";
|
||||
assert_eq!(from_str::<Foo>(xml), Ok(v.clone()));
|
||||
|
||||
let xml = "<!--comment--><Foo flag=\"true\"><!--comment-->cbdté</Foo><!--comment-->";
|
||||
assert_eq!(from_str::<Foo>(xml), Ok(v));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue