Struct VacantEntry

struct VacantEntry<'a> { ... }

A vacant Entry. It is part of the Entry enum.

Implementations

impl<'a> VacantEntry<'a>

fn key(self: &Self) -> &String

Gets a reference to the key that would be used when inserting a value through the VacantEntry.

Examples

use serde_json::map::Entry;

let mut map = serde_json::Map::new();

match map.entry("serde") {
    Entry::Vacant(vacant) => {
        assert_eq!(vacant.key(), &"serde");
    }
    Entry::Occupied(_) => unimplemented!(),
}
fn insert(self: Self, value: Value) -> &'a mut Value

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

Examples

# use serde_json::json;
#
use serde_json::map::Entry;

let mut map = serde_json::Map::new();

match map.entry("serde") {
    Entry::Vacant(vacant) => {
        vacant.insert(json!("hoho"));
    }
    Entry::Occupied(_) => unimplemented!(),
}

impl<'a> Freeze for VacantEntry<'a>

impl<'a> RefUnwindSafe for VacantEntry<'a>

impl<'a> Send for VacantEntry<'a>

impl<'a> Sync for VacantEntry<'a>

impl<'a> Unpin for VacantEntry<'a>

impl<'a> UnwindSafe for VacantEntry<'a>

impl<T> Any for VacantEntry<'a>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for VacantEntry<'a>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for VacantEntry<'a>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> From for VacantEntry<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for VacantEntry<'a>

fn into(self: Self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom for VacantEntry<'a>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for VacantEntry<'a>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>