Struct toml_edit::InlineTable
source · pub struct InlineTable { /* private fields */ }
Expand description
Type representing a TOML inline table,
payload of the Value::InlineTable
variant
Implementations§
source§impl InlineTable
impl InlineTable
Constructors
See also FromIterator
sourcepub fn into_table(self) -> Table
pub fn into_table(self) -> Table
Convert to a table
source§impl InlineTable
impl InlineTable
Formatting
sourcepub fn get_values(&self) -> Vec<(Vec<&Key>, &Value)>
pub fn get_values(&self) -> Vec<(Vec<&Key>, &Value)>
Get key/values for values that are visually children of this table
For example, this will return dotted keys
sourcepub fn sort_values(&mut self)
pub fn sort_values(&mut self)
Sorts the key/value pairs by key.
sourcepub fn sort_values_by<F>(&mut self, compare: F)
pub fn sort_values_by<F>(&mut self, compare: F)
Sort Key/Value Pairs of the table using the using the comparison function compare
.
The comparison function receives two key and value pairs to compare (you can sort by keys or values or their combination as needed).
sourcepub fn set_dotted(&mut self, yes: bool)
pub fn set_dotted(&mut self, yes: bool)
Change this table’s dotted status
sourcepub fn is_dotted(&self) -> bool
pub fn is_dotted(&self) -> bool
Check if this is a wrapper for dotted keys, rather than a standard table
sourcepub fn key_decor_mut(&mut self, key: &str) -> Option<&mut Decor>
pub fn key_decor_mut(&mut self, key: &str) -> Option<&mut Decor>
Returns the decor associated with a given key of the table.
sourcepub fn key_decor(&self, key: &str) -> Option<&Decor>
pub fn key_decor(&self, key: &str) -> Option<&Decor>
Returns the decor associated with a given key of the table.
sourcepub fn set_preamble(&mut self, preamble: impl Into<RawString>)
pub fn set_preamble(&mut self, preamble: impl Into<RawString>)
Set whitespace after before element
source§impl InlineTable
impl InlineTable
sourcepub fn iter(&self) -> InlineTableIter<'_>
pub fn iter(&self) -> InlineTableIter<'_>
Returns an iterator over key/value pairs.
sourcepub fn iter_mut(&mut self) -> InlineTableIterMut<'_>
pub fn iter_mut(&mut self) -> InlineTableIterMut<'_>
Returns an iterator over key/value pairs.
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears the table, removing all key-value pairs. Keeps the allocated memory for reuse.
sourcepub fn entry(&mut self, key: impl Into<InternalString>) -> InlineEntry<'_>
pub fn entry(&mut self, key: impl Into<InternalString>) -> InlineEntry<'_>
Gets the given key’s corresponding entry in the Table for in-place manipulation.
sourcepub fn entry_format<'a>(&'a mut self, key: &Key) -> InlineEntry<'a>
pub fn entry_format<'a>(&'a mut self, key: &Key) -> InlineEntry<'a>
Gets the given key’s corresponding entry in the Table for in-place manipulation.
sourcepub fn get(&self, key: &str) -> Option<&Value>
pub fn get(&self, key: &str) -> Option<&Value>
Return an optional reference to the value at the given the key.
sourcepub fn get_mut(&mut self, key: &str) -> Option<&mut Value>
pub fn get_mut(&mut self, key: &str) -> Option<&mut Value>
Return an optional mutable reference to the value at the given the key.
sourcepub fn get_key_value<'a>(&'a self, key: &str) -> Option<(&'a Key, &'a Item)>
pub fn get_key_value<'a>(&'a self, key: &str) -> Option<(&'a Key, &'a Item)>
Return references to the key-value pair stored for key, if it is present, else None.
sourcepub fn get_key_value_mut<'a>(
&'a mut self,
key: &str,
) -> Option<(KeyMut<'a>, &'a mut Item)>
pub fn get_key_value_mut<'a>( &'a mut self, key: &str, ) -> Option<(KeyMut<'a>, &'a mut Item)>
Return mutable references to the key-value pair stored for key, if it is present, else None.
sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Returns true iff the table contains given key.
sourcepub fn get_or_insert<V: Into<Value>>(
&mut self,
key: impl Into<InternalString>,
value: V,
) -> &mut Value
pub fn get_or_insert<V: Into<Value>>( &mut self, key: impl Into<InternalString>, value: V, ) -> &mut Value
Inserts a key/value pair if the table does not contain the key. Returns a mutable reference to the corresponding value.
sourcepub fn insert(
&mut self,
key: impl Into<InternalString>,
value: Value,
) -> Option<Value>
pub fn insert( &mut self, key: impl Into<InternalString>, value: Value, ) -> Option<Value>
Inserts a key-value pair into the map.
sourcepub fn insert_formatted(&mut self, key: &Key, value: Value) -> Option<Value>
pub fn insert_formatted(&mut self, key: &Key, value: Value) -> Option<Value>
Inserts a key-value pair into the map.
Trait Implementations§
source§impl Clone for InlineTable
impl Clone for InlineTable
source§fn clone(&self) -> InlineTable
fn clone(&self) -> InlineTable
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for InlineTable
impl Debug for InlineTable
source§impl Default for InlineTable
impl Default for InlineTable
source§fn default() -> InlineTable
fn default() -> InlineTable
source§impl Display for InlineTable
impl Display for InlineTable
source§impl<K: Into<Key>, V: Into<Value>> Extend<(K, V)> for InlineTable
impl<K: Into<Key>, V: Into<Value>> Extend<(K, V)> for InlineTable
source§fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)