pub struct InlineTable {
preamble: RawString,
pub(crate) implicit: bool,
decor: Decor,
pub(crate) span: Option<Range<usize>>,
dotted: bool,
pub(crate) items: IndexMap<Key, Item>,
}Fields§
§preamble: RawString§implicit: bool§decor: Decor§span: Option<Range<usize>>§dotted: bool§items: IndexMap<Key, Item>Implementations§
Source§impl InlineTable
Constructors
impl InlineTable
Constructors
See also FromIterator
pub(crate) fn with_pairs(items: IndexMap<Key, Item>) -> Self
Sourcepub fn into_table(self) -> Table
pub fn into_table(self) -> Table
Convert to a table
Source§impl InlineTable
Formatting
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
pub(crate) fn append_values<'s>( &'s self, parent: &[&'s Key], values: &mut Vec<(Vec<&'s Key>, &'s Value)>, )
Sourcepub fn sort_values(&mut self)
pub fn sort_values(&mut self)
Sourcepub fn sort_values_by<F>(&mut self, compare: F)
pub fn sort_values_by<F>(&mut self, compare: F)
fn sort_values_by_internal<F>(&mut self, compare: &mut F)
Sourcepub(crate) fn set_implicit(&mut self, implicit: bool)
pub(crate) fn set_implicit(&mut self, implicit: bool)
If a table has no key/value pairs and implicit, it will not be displayed.
§Examples
[target."x86_64/windows.json".dependencies]In the document above, tables target and target."x86_64/windows.json" are implicit.
use toml_edit::DocumentMut;
let mut doc = "[a]\n[a.b]\n".parse::<DocumentMut>().expect("invalid toml");
doc["a"].as_table_mut().unwrap().set_implicit(true);
assert_eq!(doc.to_string(), "[a.b]\n");Sourcepub(crate) fn is_implicit(&self) -> bool
pub(crate) fn is_implicit(&self) -> bool
If a table has no key/value pairs and implicit, it will not be displayed.
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_mut(&mut self, key: &str) -> Option<KeyMut<'_>>
pub fn key_mut(&mut self, key: &str) -> Option<KeyMut<'_>>
Returns an accessor to a key’s formatting
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
Sourcepub fn span(&self) -> Option<Range<usize>>
pub fn span(&self) -> Option<Range<usize>>
The location within the original document
This generally requires a Document.
pub(crate) fn despan(&mut self, input: &str)
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<String>) -> InlineEntry<'_>
pub fn entry(&mut self, key: impl Into<String>) -> 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 if the table contains given key.
Sourcepub fn get_or_insert<V: Into<Value>>(
&mut self,
key: impl Into<String>,
value: V,
) -> &mut Value
pub fn get_or_insert<V: Into<Value>>( &mut self, key: impl Into<String>, 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<String>, value: Value) -> Option<Value>
pub fn insert(&mut self, key: impl Into<String>, 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<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)