pub fn from_str_borrowed<'input, 'facet, T>(
input: &'input str,
) -> Result<T, DeserializeError<JsonError>>where
T: Facet<'facet>,
'input: 'facet,Expand description
Deserialize a value from a JSON string, 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_str which doesn’t have lifetime requirements.
§Example
use facet::Facet;
use facet_json::from_str_borrowed;
#[derive(Facet, Debug, PartialEq)]
struct Person<'a> {
name: &'a str,
age: u32,
}
let json = r#"{"name": "Alice", "age": 30}"#;
let person: Person = from_str_borrowed(json).unwrap();
assert_eq!(person.name, "Alice");
assert_eq!(person.age, 30);