pub struct Field<'buf> { /* private fields */ }Expand description
An object field; upholds the invariant that the inner Element’s path ends with a key.
Implementations§
Source§impl<'buf> Field<'buf>
impl<'buf> Field<'buf>
Sourcepub fn into_element(self) -> Element<'buf>
pub fn into_element(self) -> Element<'buf>
Consume the Field and return the inner Element.
pub fn key_span(&self) -> Span
Sourcepub fn full_span(&self) -> Span
pub fn full_span(&self) -> Span
Returns the span covering "key": value plus any trailing comma and whitespace.
Choose the removal span based on the field’s position in its parent:
| Case | Span to erase |
|---|---|
| Remove non-last field | field.full_span() |
| Remove last field (siblings exist) | fields[i-1].element().span().end .. field.element().span().end |
| Remove only field | field.element().span() |
When there is no trailing comma (last field), full_span() covers
"key": value only. Erasing it leaves a dangling comma on the previous
field; use the predecessor’s element().span().end as the start instead.
Sourcepub fn source_json(&self) -> &'buf str
pub fn source_json(&self) -> &'buf str
Returns the slice of the source JSON spanning "key": value.
Trait Implementations§
impl<'buf> Eq for Field<'buf>
Source§impl<'buf> PartialEq for Field<'buf>
impl<'buf> PartialEq for Field<'buf>
impl<'buf> StructuralPartialEq for Field<'buf>
Auto Trait Implementations§
impl<'buf> !Send for Field<'buf>
impl<'buf> !Sync for Field<'buf>
impl<'buf> Freeze for Field<'buf>
impl<'buf> RefUnwindSafe for Field<'buf>
impl<'buf> Unpin for Field<'buf>
impl<'buf> UnsafeUnpin for Field<'buf>
impl<'buf> UnwindSafe for Field<'buf>
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