See the discussion in tokio-rs/axum#1781 (comment) for the original issue & motivation.
TL;DR is that Header::decode allows each typed header to handle empty iterators in its own way and let the header implementation decide whether missing header is an error or whether to provide some default "parsed" value (e.g. empty collection), but HeaderMapExt::typed_{try_}get always return Option::None when header is not found in the HeaderMap, not giving such Header implementation a chance to correctly provide their own fallback.
It would be useful to have variation of those methods that always return Result<H, Error> by forwarding an empty iterator to the specific H::decode implementation and letting it decide whether to provide a Ok(fallback_value) or emit an error.
See the discussion in tokio-rs/axum#1781 (comment) for the original issue & motivation.
TL;DR is that
Header::decodeallows each typed header to handle empty iterators in its own way and let the header implementation decide whether missing header is an error or whether to provide some default "parsed" value (e.g. empty collection), butHeaderMapExt::typed_{try_}getalways returnOption::Nonewhen header is not found in theHeaderMap, not giving suchHeaderimplementation a chance to correctly provide their own fallback.It would be useful to have variation of those methods that always return
Result<H, Error>by forwarding an empty iterator to the specificH::decodeimplementation and letting it decide whether to provide aOk(fallback_value)or emit an error.