Struct json5format::Array
source · pub struct Array { /* private fields */ }
Expand description
Represents a JSON5 array of items. During parsing, this object’s state changes, as comments and items are encountered. Parsed comments are temporarily stored in contained_comments, to be transferred to the next parsed item. After the last item, if any other comments are encountered, those comments are retained in the contained_comments field, to be restored during formatting, after writing the last item.
Implementations§
source§impl Array
impl Array
sourcepub fn items(&self) -> impl Iterator<Item = Ref<'_, Value>>
pub fn items(&self) -> impl Iterator<Item = Ref<'_, Value>>
Returns an iterator over the array items. Items must be dereferenced to access
the Value
. For example:
use json5format::*;
let parsed_document = ParsedDocument::from_str("{}", None)?;
for item in parsed_document.content.items() {
assert!(!(*item).is_primitive());
}
sourcepub fn items_mut(&mut self) -> impl Iterator<Item = RefMut<'_, Value>>
pub fn items_mut(&mut self) -> impl Iterator<Item = RefMut<'_, Value>>
As in Array::items
, returns an iterator over the array items, but with mutable references.
sourcepub fn trailing_comments(&self) -> &Vec<Comment>
pub fn trailing_comments(&self) -> &Vec<Comment>
Returns a reference to the comments at the end of an array not associated with any values.
sourcepub fn trailing_comments_mut(&mut self) -> &mut Vec<Comment>
pub fn trailing_comments_mut(&mut self) -> &mut Vec<Comment>
Returns a mutable reference to the comments at the end of an array not associated with any values.