pub(crate) struct Mapping {
shape: Shape,
entries: Vec<Entry>,
indent: usize,
step: usize,
}Expand description
A mapping whose entries can be listed, replaced, appended, and removed.
Fields§
§shape: Shape§entries: Vec<Entry>§indent: usize§step: usizeImplementations§
Source§impl Mapping
impl Mapping
Sourcepub(super) const fn block(
opening: Text,
entries: Vec<Entry>,
indent: usize,
step: usize,
) -> Self
pub(super) const fn block( opening: Text, entries: Vec<Entry>, indent: usize, step: usize, ) -> Self
A block mapping whose keys sit at indent, with nested mappings
step columns deeper.
Sourcepub(super) const fn empty_flow(
before: Text,
braces: Text,
after: Text,
indent: usize,
step: usize,
) -> Self
pub(super) const fn empty_flow( before: Text, braces: Text, after: Text, indent: usize, step: usize, ) -> Self
An empty flow mapping whose block entries will sit at indent.
Sourcepub(super) fn reopened(self, opening: Text, indent: usize, step: usize) -> Self
pub(super) fn reopened(self, opening: Text, indent: usize, step: usize) -> Self
This mapping opened by opening, with its keys moved to indent and
nested mappings step columns deeper.
Sourcepub(super) fn take_header(&mut self) -> Text
pub(super) fn take_header(&mut self) -> Text
Split off the leading text of the first entry, except for the comment block directly above its key.
pub(crate) fn keys(&self) -> impl Iterator<Item = &str>
pub(crate) fn get(&self, key: &str) -> Option<&Entry>
pub(crate) fn get_mut(&mut self, key: &str) -> Option<&mut Entry>
Sourcepub(crate) fn insert(&mut self, entry: Entry)
pub(crate) fn insert(&mut self, entry: Entry)
Put entry in the mapping, laid out at this mapping’s indent and
step.
An entry with the same key is replaced in place. It keeps the existing key text, trailing comment of a plain value, and leading text unless the new entry brings a comment. Any other entry is appended.
Sourcepub(crate) fn remove(&mut self, key: &str)
pub(crate) fn remove(&mut self, key: &str)
Remove the entry with key, together with its leading text.
A mapping left without entries becomes {}.
Sourcepub(super) fn comment(&self) -> Option<&str>
pub(super) fn comment(&self) -> Option<&str>
The comment on the key line, with the whitespace before it.
Sourcepub(super) fn keep_comment(&mut self, comment: &str)
pub(super) fn keep_comment(&mut self, comment: &str)
Put comment on the key line unless it has one.
const fn key_line_mut(&mut self) -> &mut Text
Sourcepub(super) fn collapse(&mut self)
pub(super) fn collapse(&mut self)
Turn an emptied block mapping into {}, as an empty value would read
back as null. Anchors and a trailing comment stay.
Sourcefn reindent_to(&mut self, indent: usize, step: usize)
fn reindent_to(&mut self, indent: usize, step: usize)
Move the keys to indent and nested mappings to step columns per
level, carrying every entry’s lines along.
Trait Implementations§
impl Eq for Mapping
impl StructuralPartialEq for Mapping
Auto Trait Implementations§
impl Freeze for Mapping
impl RefUnwindSafe for Mapping
impl Send for Mapping
impl Sync for Mapping
impl Unpin for Mapping
impl UnsafeUnpin for Mapping
impl UnwindSafe for Mapping
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
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
key and return true if they are equal.