pub enum JsonStr<'de> {
Borrowed(&'de str),
BorrowedNoEsc(&'de str),
Owned(String),
}Expand description
A parsed JSON string: either a zero-copy borrow or a heap-allocated value.
The BorrowedNoEsc variant is returned by Scanner::read_str when no
escape sequences were present in the JSON input. This lets the serializer
skip the find_escape scan entirely — the string is provably escape-free.
Variants§
Borrowed(&'de str)
Zero-copy borrow from the input. No longer emitted by Scanner::read_str
(use JsonStr::BorrowedNoEsc instead); kept for API compatibility.
ToJson will run write_escaped_str on this variant.
BorrowedNoEsc(&'de str)
Zero-copy borrow whose content is provably escape-free (the scanner
hit a closing " before any \\). The serializer can bypass the
find_escape scan and write the bytes directly.
Owned(String)
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<'de> Freeze for JsonStr<'de>
impl<'de> RefUnwindSafe for JsonStr<'de>
impl<'de> Send for JsonStr<'de>
impl<'de> Sync for JsonStr<'de>
impl<'de> Unpin for JsonStr<'de>
impl<'de> UnsafeUnpin for JsonStr<'de>
impl<'de> UnwindSafe for JsonStr<'de>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more