pub struct VacantEntry<'a, T> where
T: 'a + 'a, { /* fields omitted */ }
A view into a single empty location in a HeaderMap
.
This struct is returned as part of the Entry
enum.
Returns a reference to the entry's key
let mut map = HeaderMap::new();
assert_eq!(map.entry("x-hello").unwrap().key().as_str(), "x-hello");
Take ownership of the key
let mut map = HeaderMap::new();
if let Entry::Vacant(v) = map.entry("x-hello").unwrap() {
assert_eq!(v.into_key().as_str(), "x-hello");
}
Insert the value into the entry.
The value will be associated with this entry's key. A mutable reference
to the inserted value will be returned.
let mut map = HeaderMap::new();
if let Entry::Vacant(v) = map.entry("x-hello").unwrap() {
v.insert("world".parse().unwrap());
}
assert_eq!(map["x-hello"], "world");
pub fn insert_entry(self, value: T) -> OccupiedEntry<'a, T> | [src] |
Insert the value into the entry.
The value will be associated with this entry's key. The new
OccupiedEntry
is returned, allowing for further manipulation.
let mut map = HeaderMap::new();
if let Entry::Vacant(v) = map.entry("x-hello").unwrap() {
let mut e = v.insert_entry("world".parse().unwrap());
e.insert("world2".parse().unwrap());
}
assert_eq!(map["x-hello"], "world2");
Formats the value using the given formatter. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static