1
0
Fork 0
mirror of https://gitlab.com/msrd0/gotham-restful.git synced 2025-02-23 04:52:28 +00:00

no need to use stringify! in a proc macro

This commit is contained in:
Dominic 2020-05-09 18:10:50 +02:00
parent b9002bd70d
commit 40c90e6b4a
Signed by: msrd0
GPG key ID: DCC8C247452E98F9

View file

@ -16,6 +16,7 @@ use syn::{
Generics, Generics,
GenericParam, GenericParam,
Lit, Lit,
LitStr,
Meta, Meta,
NestedMeta, NestedMeta,
Result, Result,
@ -175,6 +176,7 @@ fn expand_field(field : &Field) -> Result<TokenStream>
Some(ident) => ident, Some(ident) => ident,
None => return Err(Error::new(field.span(), "#[derive(OpenapiType)] does not support fields without an ident")) None => return Err(Error::new(field.span(), "#[derive(OpenapiType)] does not support fields without an ident"))
}; };
let ident_str = LitStr::new(&ident.to_string(), ident.span());
let ty = &field.ty; let ty = &field.ty;
let attrs = parse_attributes(&field.attrs)?; let attrs = parse_attributes(&field.attrs)?;
@ -193,7 +195,7 @@ fn expand_field(field : &Field) -> Result<TokenStream>
} }
else if !#nullable else if !#nullable
{ {
required.push(stringify!(#ident).to_string()); required.push(#ident_str.to_string());
} }
let keys : Vec<String> = schema.dependencies.keys().map(|k| k.to_string()).collect(); let keys : Vec<String> = schema.dependencies.keys().map(|k| k.to_string()).collect();