pub fn from_slice_borrowed<'input, 'facet, T>(
input: &'input [u8],
) -> Result<T, DeserializeError<JsonError>>where
T: Facet<'facet>,
'input: 'facet,Expand description
Deserialize a value from JSON 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_json::from_slice_borrowed;
#[derive(Facet, Debug, PartialEq)]
struct Point<'a> {
label: &'a str,
x: i32,
y: i32,
}
let json = br#"{"label": "origin", "x": 0, "y": 0}"#;
let point: Point = from_slice_borrowed(json).unwrap();
assert_eq!(point.label, "origin");