Add some extra borrowing tests
This commit is contained in:
parent
20f73b7e01
commit
d2605977aa
|
@ -0,0 +1,27 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use similar_asserts::assert_eq;
|
||||
|
||||
use instant_xml::{from_str, to_string, FromXml, ToXml};
|
||||
|
||||
#[derive(Debug, Eq, FromXml, PartialEq, ToXml)]
|
||||
struct Foo {
|
||||
bar: Bar<'static>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, FromXml, PartialEq, ToXml)]
|
||||
struct Bar<'a> {
|
||||
baz: Cow<'a, str>,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lifetime() {
|
||||
let v = Foo {
|
||||
bar: Bar {
|
||||
baz: Cow::Borrowed("hello"),
|
||||
},
|
||||
};
|
||||
let xml = r#"<Foo><Bar><baz>hello</baz></Bar></Foo>"#;
|
||||
assert_eq!(xml, to_string(&v).unwrap());
|
||||
assert_eq!(v, from_str(xml).unwrap());
|
||||
}
|
Loading…
Reference in New Issue