mirror of
https://github.com/instant-labs/instant-xml.git
synced 2025-02-03 00:24:21 +00:00
Add some extra borrowing tests
This commit is contained in:
parent
20f73b7e01
commit
d2605977aa
27
instant-xml/tests/lifetime.rs
Normal file
27
instant-xml/tests/lifetime.rs
Normal file
@ -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
Block a user