Enum tauri::http::header::Entry
x3A;:header::Entry,
pub enum Entry<'a, T> where
T: 'a, {
Occupied(OccupiedEntry<'a, T>),
Vacant(VacantEntry<'a, T>),
}
Expand description
A view into a single location in a HeaderMap
, which may be vacant or occupied.
#
VariantsOccupied(OccupiedEntry<'a, T>)
An occupied entry
Vacant(VacantEntry<'a, T>)
A vacant entry
#
ImplementationsEntry<'a, T>[src]#
impl<'a, T>or_insert(self, default: T) -> &'a mutT[src]#
pub fnEnsures a value is in the entry by inserting the default if empty.
Returns a mutable reference to the first value in the entry.
#
Exampleslet mut map: HeaderMap<u32> = HeaderMap::default();
let headers = &[
"content-length",
"x-hello",
"Content-Length",
"x-world",
];
for &header in headers {
let counter = map.entry(header)
.or_insert(0);
*counter += 1;
}
assert_eq!(map["content-length"], 2);
assert_eq!(map["x-hello"], 1);
or_insert_with<F>(self, default: F) -> &'a mutT where F: FnOnce() -> T,[src]#
pub fnEnsures a value is in the entry by inserting the result of the default function if empty.
The default function is not called if the entry exists in the map. Returns a mutable reference to the first value in the entry.
#
ExamplesBasic usage.
let mut map = HeaderMap::new();
let res = map.entry("x-hello")
.or_insert_with(|| "world".parse().unwrap());
assert_eq!(res, "world");
The default function is not called if the entry exists in the map.
let mut map = HeaderMap::new();
map.insert(HOST, "world".parse().unwrap());
let res = map.entry("host")
.or_insert_with(|| unreachable!());
assert_eq!(res, "world");
key(&self) -> &HeaderName[src]#
pub fnReturns a reference to the entry’s key
#
Exampleslet mut map = HeaderMap::new();
assert_eq!(map.entry("x-hello").key(), "x-hello");
#
Trait ImplementationsDebug for Entry<'a, T> where T: 'a + Debug,[src]#
impl<'a, T>fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]#
pub fnFormats the value using the given formatter. Read more
#
Auto Trait ImplementationsRefUnwindSafe for Entry<'a, T> where T: RefUnwindSafe,#
impl<'a, T>Send for Entry<'a, T> where T: Send,#
impl<'a, T>Sync for Entry<'a, T> where T: Sync,#
impl<'a, T>Unpin for Entry<'a, T>#
impl<'a, T>UnwindSafe for Entry<'a, T>#
impl<'a, T> \!#
Blanket ImplementationsAny for T where T: 'static + ?Sized,[src]#
impl<T>type_id(&self) -> TypeId[src]#
pub fnGets the TypeId
of self
. Read more
Borrow<T> for T where T: ?Sized,[src]#
impl<T>borrow(&self) -> &T[src]#
pub fnImmutably borrows from an owned value. Read more
BorrowMut<T> for T where T: ?Sized,[src]#
impl<T>borrow_mut(&mut self) -> &mutT[src]#
pub fnMutably borrows from an owned value. Read more
From<T> for T[src]#
impl<T>from(t: T) -> T[src]#
pub fnPerforms the conversion.
Into<U> for T where U: From<T>,[src]#
impl<T, U>into(self) -> U[src]#
pub fnPerforms the conversion.
TryFrom<U> for T where U: Into<T>,[src]#
impl<T, U>Error = Infallible#
typeThe type returned in the event of a conversion error.
try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]#
pub fnPerforms the conversion.
TryInto<U> for T where U: TryFrom<T>,[src]#
impl<T, U>Error = <U as TryFrom<T>>::Error#
typeThe type returned in the event of a conversion error.
try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]#
pub fnPerforms the conversion.