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

future-proof FromForm against scope resolution changes #705

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions core/codegen_next/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,15 @@ fn real_derive_from_form_value(input: TokenStream) -> PResult<TokenStream> {

// Generate the implementation.
Ok(quote! {
mod scope {
extern crate std;
extern crate rocket;
impl<'v> ::rocket::request::FromFormValue<'v> for #name {
type Error = &'v ::rocket::http::RawStr;

use self::std::prelude::v1::*;
use self::rocket::request::FromFormValue;
use self::rocket::http::RawStr;
fn from_form_value(v: &'v ::rocket::http::RawStr) -> ::std::result::Result<Self, Self::Error> {
#(if v.as_uncased_str() == #variant_strs {
return ::std::result::Result::Ok(#names::#variant_idents);
})*

impl<'v> FromFormValue<'v> for #name {
type Error = &'v RawStr;

fn from_form_value(v: &'v RawStr) -> Result<Self, Self::Error> {
#(if v.as_uncased_str() == #variant_strs {
return Ok(#names::#variant_idents);
})*

Err(v)
}
::std::result::Result::Err(v)
}
}
}.into())
Expand Down