Skip to content

Commit dfb795a

Browse files
committed
Make enums owned
1 parent b384b0c commit dfb795a

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

graphql_query_derive/src/enums.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ impl GqlEnum {
2222
let name = Ident::new(&self.name, Span::call_site());
2323

2424
quote! {
25-
pub enum #name<'a> {
25+
pub enum #name {
2626
#(#variants,)*
27-
Other(&'a str),
27+
Other(String),
2828
}
2929

3030
impl ::serde::Serialize for #name {
3131
fn serialize<S: serde::Serializer>(&self, ser: S) -> Result<S::Ok, S::Error> {
3232
ser.serialize_str(match *self {
3333
#(#constructors => #variant_str,)*
34-
#name::Other(s) => s,
34+
#name::Other(s) => s.as_str(),
3535
})
3636
}
3737
}
@@ -42,7 +42,7 @@ impl GqlEnum {
4242

4343
match s {
4444
#(#variant_str => Ok(#constructors),)*
45-
_ => #name::Other(s),
45+
_ => Ok(#name::Other(s.to_string())),
4646
}
4747
}
4848
}

graphql_query_derive/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn impl_gql_query(input: &syn::DeriveInput) -> Result<TokenStream, failure::Erro
7777
type Variables = #module_name::Variables;
7878
type ResponseData = #module_name::ResponseData;
7979

80-
fn build_query(variables: &Self::Variables) -> ::graphql_query::GraphQLQueryBody<Self::Variables> {
80+
fn build_query(variables: Self::Variables) -> ::graphql_query::GraphQLQueryBody<Self::Variables> {
8181
::graphql_query::GraphQLQueryBody {
8282
variables,
8383
query: #module_name::QUERY,

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub trait GraphQLQuery<'de> {
1515
type ResponseData: serde::Deserialize<'de>;
1616

1717
/// Produce a GraphQL query struct that can be JSON serialized and sent to a GraphQL API.
18-
fn build_query(variables: &Self::Variables) -> GraphQLQueryBody<Self::Variables>;
18+
fn build_query(variables: Self::Variables) -> GraphQLQueryBody<Self::Variables>;
1919
}
2020

2121
#[derive(Serialize)]

0 commit comments

Comments
 (0)