Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop IntoResponse trait requirement from FromRequestParts and FromRequest Rejections #2869

Open
1 task done
MOZGIII opened this issue Aug 8, 2024 · 1 comment
Open
1 task done

Comments

@MOZGIII
Copy link

MOZGIII commented Aug 8, 2024

  • I have looked for existing issues (including closed) about this

Feature Request

Motivation

Optional extractors don't need the rejection to implement IntoResponse. Providing an extraction with a Rejection that doesn't implement IntoResponse will indicate this extractor must be used as optional.

This is a required feature for enforcing certain response shapes via the type system.

Proposal

Make the following changes (simplified):

pub trait FromRequestParts<S>: Sized {
-    type Rejection: IntoResponse;
+    type Rejection;
pub trait FromRequest<S, M = private::ViaRequest>: Sized { {
-    type Rejection: IntoResponse;
+    type Rejection;

Alternatives

@MOZGIII MOZGIII changed the title Drop IntoResponse trait requirement from FromRequestParts and FromRequest Drop IntoResponse trait requirement from FromRequestParts and FromRequest Rejections Aug 8, 2024
@mladedav
Copy link
Collaborator

mladedav commented Aug 9, 2024

There may be another trait for optional extractors, see #2475. It would allow pretty much what you're proposing by using Infallible as the rejection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants