pub struct InlineVacantEntry<'a> { /* private fields */ }
Expand description

A view into a single empty location in a IndexMap.

Implementations§

Gets a reference to the entry key

Examples
use toml_edit::Table;

let mut map = Table::new();

assert_eq!("foo", map.entry("foo").key());
Examples found in repository?
src/inline_table.rs (line 519)
516
517
518
519
520
521
    pub fn key(&self) -> &str {
        match self {
            InlineEntry::Occupied(e) => e.key(),
            InlineEntry::Vacant(e) => e.key(),
        }
    }

Sets the value of the entry with the VacantEntry’s key, and returns a mutable reference to it

Examples found in repository?
src/inline_table.rs (line 528)
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
    pub fn or_insert(self, default: Value) -> &'a mut Value {
        match self {
            InlineEntry::Occupied(entry) => entry.into_mut(),
            InlineEntry::Vacant(entry) => entry.insert(default),
        }
    }

    /// Ensures a value is in the entry by inserting the result of the default function if empty,
    /// and returns a mutable reference to the value in the entry.
    pub fn or_insert_with<F: FnOnce() -> Value>(self, default: F) -> &'a mut Value {
        match self {
            InlineEntry::Occupied(entry) => entry.into_mut(),
            InlineEntry::Vacant(entry) => entry.insert(default()),
        }
    }

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.