Open jplatte opened 1 year ago
Are body extractors ever infallible / does it make sense to provide RequestExt::extract_infallible?
Body
itself is infallible as it pretty much just provides the underlying stream. Anything that actually collects the bytes would be fallible though. I don't think it makes much sense to add extract_infallible
for that case though.
But it does make sense to me for request parts.
I think this can be closed now since in the 1.82 you can just match the result with infallible https://blog.rust-lang.org/2024/10/17/Rust-1.82.0.html#omitting-empty-types-in-pattern-matching.
Feature Request
Motivation
Some extractors such as
CookieJar
use anInfallible
rejection type. Currently, one has to use.unwrap()
/.expect("infallible")
/.unwrap_or_else(|i| match i {})
after the actual extraction function call to get rid of it.Proposal
RequestPartsExt::extract_infallible
(andextract_infallible_with_state
RequestExt::extract_parts_infallible
, ...) for 0.7.xextract
methods on the extension traits totry_extract
and removing the_infallible
suffix for 0.8.xAlternatives
ResultExt
with our own variant ofResult::into_ok
.Open questions
Are body extractors ever infallible / does it make sense to provide
RequestExt::extract_infallible
?