pub(crate) struct Value {
pub(super) leading: Trivia,
pub(super) kind: Kind,
}Expand description
A value with the trivia that precedes it.
For an object member or an array item the leading trivia is everything since the previous element, so a comment above a member moves with its value. In an object member it comes before the key.
Fields§
§leading: Trivia§kind: KindImplementations§
Source§impl Value
impl Value
pub(super) const fn new(leading: Trivia, kind: Kind) -> Self
pub(super) const fn is_object(&self) -> bool
pub(super) const fn as_object(&self) -> Option<&Object>
pub(super) const fn as_object_mut(&mut self) -> Option<&mut Object>
fn build( node: &Annotated, dialect: Dialect, depth: usize, leading: Trivia, ) -> Self
fn write(&self, f: &mut Formatter<'_>, dialect: Dialect) -> Result
Sourcefn trivia_mut(&mut self, visit: &mut dyn FnMut(&mut Trivia))
fn trivia_mut(&mut self, visit: &mut dyn FnMut(&mut Trivia))
Visit every piece of trivia in the value, including its leading trivia.
Sourcefn reindent_unit(&mut self, unit: &Indent)
fn reindent_unit(&mut self, unit: &Indent)
Convert the indent of every line from the canonical two spaces per
level to unit, including the leading trivia.
Trait Implementations§
impl Eq for Value
Source§impl Node for Value
impl Node for Value
Source§fn is_container(&self) -> bool
fn is_container(&self) -> bool
Whether this node holds keyed children.
fn child(&self, key: &str) -> Option<&Self>
fn child_mut(&mut self, key: &str) -> Option<&mut Self>
Source§fn adopt(&mut self, key: &str, source: &Self)
fn adopt(&mut self, key: &str, source: &Self)
Take the child
key from source, replacing the existing child or
appending. An existing child keeps its decor unless the desired child
brings a comment of its own, which replaces the leading comment.Source§fn adopt_shell(&mut self, key: &str, source: &Self)
fn adopt_shell(&mut self, key: &str, source: &Self)
Insert an empty container for the child
key of source, with the
decor and comment of that child.fn remove(&mut self, key: &str)
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnsafeUnpin for Value
impl UnwindSafe for Value
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.