Support #[derive(FromRequest)] on enums (#1009)

* Support `#[from_request(via(...))]` on enums

* Check `#[from_request]` on variants

* check for non enum/struct and clean up

* changelog

* changelog

* remove needless feature

* changelog ref
This commit is contained in:
David Pedersen
2022-05-08 20:04:56 +02:00
committed by GitHub
parent a3a32f493e
commit 852e548e19
14 changed files with 215 additions and 25 deletions
+4 -2
View File
@@ -12,7 +12,7 @@ pub(crate) struct FromRequestFieldAttr {
pub(crate) enum FromRequestContainerAttr {
Via(syn::Path),
RejectionDerive(RejectionDeriveOptOuts),
RejectionDerive(kw::rejection_derive, RejectionDeriveOptOuts),
None,
}
@@ -91,7 +91,9 @@ pub(crate) fn parse_container_attrs(
}
}
(Some((_, _, path)), None) => Ok(FromRequestContainerAttr::Via(path)),
(None, Some((_, _, opt_outs))) => Ok(FromRequestContainerAttr::RejectionDerive(opt_outs)),
(None, Some((_, rejection_derive, opt_outs))) => Ok(
FromRequestContainerAttr::RejectionDerive(rejection_derive, opt_outs),
),
(None, None) => Ok(FromRequestContainerAttr::None),
}
}