pub fn from_slice_borrowed<'input, 'facet, T>(
input: &'input [u8],
) -> Result<T, DeserializeError<XmlError>>where
T: Facet<'facet>,
'input: 'facet,Expand description
Deserialize a value from XML bytes, allowing zero-copy borrowing.
This variant requires the input to outlive the result ('input: 'facet),
enabling zero-copy deserialization of string fields as &str or Cow<str>.
Use this when you need maximum performance and can guarantee the input
buffer outlives the deserialized value. For most use cases, prefer
from_slice which doesn’t have lifetime requirements.
§Example
use facet::Facet;
use facet_xml::from_slice_borrowed;
#[derive(Facet, Debug, PartialEq)]
struct Person {
name: String,
age: u32,
}
let xml = b"<Person><name>Alice</name><age>30</age></Person>";
let person: Person = from_slice_borrowed(xml).unwrap();
assert_eq!(person.name, "Alice");
assert_eq!(person.age, 30);