[][src]Struct toml_edit::Table

pub struct Table { /* fields omitted */ }

Type representing a TOML non-inline table

Implementations

impl Table[src]

pub fn new() -> Self[src]

Creates an empty table.

pub fn contains_key(&self, key: &str) -> bool[src]

Returns true iff the table contains an item with the given key.

pub fn contains_table(&self, key: &str) -> bool[src]

Returns true iff the table contains a table with the given key.

pub fn contains_value(&self, key: &str) -> bool[src]

Returns true iff the table contains a value with the given key.

pub fn contains_array_of_tables(&self, key: &str) -> bool[src]

Returns true iff the table contains an array of tables with the given key.

pub fn iter(&self) -> Iter[src]

Returns an iterator over all key/value pairs, including empty.

pub fn remove(&mut self, key: &str) -> Option<Item>[src]

Removes an item given the key.

pub fn sort_values(&mut self)[src]

Sorts Key/Value Pairs of the table, doesn't affect subtables or subarrays.

pub fn len(&self) -> usize[src]

Returns the number of non-empty items in the table.

pub fn values_len(&self) -> usize[src]

Returns the number of key/value pairs in the table.

pub fn is_empty(&self) -> bool[src]

Returns true iff the table is empty.

pub fn entry<'a>(&'a mut self, key: &str) -> &'a mut Item[src]

Given the key, return a mutable reference to the value. If there is no entry associated with the given key in the table, a Item::None value will be inserted.

To insert to table, use entry to return a mutable reference and set it to the appropriate value.

pub fn get<'a>(&'a self, key: &str) -> Option<&'a Item>[src]

Returns an optional reference to an item given the key.

pub fn set_implicit(&mut self, implicit: bool)[src]

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::Document;
let mut doc = "[a]\n[a.b]\n".parse::<Document>().expect("invalid toml");

doc["a"].as_table_mut().unwrap().set_implicit(true);
assert_eq!(doc.to_string(), "[a.b]\n");

Trait Implementations

impl Clone for Table[src]

impl Debug for Table[src]

impl Default for Table[src]

impl Display for Table[src]

impl<'s> Index<&'s str> for Table[src]

type Output = Item

The returned type after indexing.

impl<'s> IndexMut<&'s str> for Table[src]

impl TableLike for Table[src]

fn iter(&self) -> Iter[src]

Returns an iterator over all subitems, including Item::None.

Auto Trait Implementations

impl RefUnwindSafe for Table

impl Send for Table

impl Sync for Table

impl Unpin for Table

impl UnwindSafe for Table

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.