From 0372de84d5f4855ee311188915d10fa87f6a222f Mon Sep 17 00:00:00 2001 From: theduke Date: Tue, 29 Aug 2017 04:48:11 +0200 Subject: [PATCH] Rename ToInputValue::to to to_input_value() --- juniper/src/ast.rs | 2 +- juniper/src/executor.rs | 2 +- juniper/src/macros/enums.rs | 2 +- juniper/src/macros/input_object.rs | 4 ++-- juniper/src/macros/scalar.rs | 6 +++--- juniper/src/types/containers.rs | 12 ++++++------ juniper/src/types/pointers.rs | 8 ++++---- juniper/src/types/scalars.rs | 2 +- juniper/src/value.rs | 6 +++--- juniper_codegen/src/derive_enum.rs | 2 +- juniper_codegen/src/derive_input_object.rs | 4 ++-- juniper_tests/src/codegen/derive_enum.rs | 4 ++-- juniper_tests/src/codegen/derive_input_object.rs | 2 +- 13 files changed, 28 insertions(+), 28 deletions(-) diff --git a/juniper/src/ast.rs b/juniper/src/ast.rs index d48d8e2b..64675fc1 100644 --- a/juniper/src/ast.rs +++ b/juniper/src/ast.rs @@ -160,7 +160,7 @@ pub trait FromInputValue: Sized { /// Losslessly clones a Rust data type into an InputValue. pub trait ToInputValue: Sized { /// Performs the conversion. - fn to(&self) -> InputValue; + fn to_input_value(&self) -> InputValue; } impl<'a> Type<'a> { diff --git a/juniper/src/executor.rs b/juniper/src/executor.rs index c830a896..bb12cb19 100644 --- a/juniper/src/executor.rs +++ b/juniper/src/executor.rs @@ -485,7 +485,7 @@ impl<'r> Registry<'r> { where T: GraphQLType + ToInputValue + FromInputValue, { - Argument::new(name, self.get_type::>(info)).default_value(value.to()) + Argument::new(name, self.get_type::>(info)).default_value(value.to_input_value()) } fn insert_placeholder(&mut self, name: Name, of_type: Type<'r>) { diff --git a/juniper/src/macros/enums.rs b/juniper/src/macros/enums.rs index d50def8b..daa1cbfa 100644 --- a/juniper/src/macros/enums.rs +++ b/juniper/src/macros/enums.rs @@ -105,7 +105,7 @@ macro_rules! graphql_enum { } impl $crate::ToInputValue for $name { - fn to(&self) -> $crate::InputValue { + fn to_input_value(&self) -> $crate::InputValue { match *self { $( graphql_enum!(@as_pattern, $eval) => diff --git a/juniper/src/macros/input_object.rs b/juniper/src/macros/input_object.rs index f69f7d70..adf43669 100644 --- a/juniper/src/macros/input_object.rs +++ b/juniper/src/macros/input_object.rs @@ -84,7 +84,7 @@ macro_rules! graphql_input_object { ) => { $crate::InputValue::object(vec![ $( - ($crate::to_camel_case(stringify!($field_name)), $selfvar.$field_name.to()) + ($crate::to_camel_case(stringify!($field_name)), $selfvar.$field_name.to_input_value()) ),* ].into_iter().collect()) }; @@ -232,7 +232,7 @@ macro_rules! graphql_input_object { } impl $crate::ToInputValue for $name { - fn to(&self) -> $crate::InputValue { + fn to_input_value(&self) -> $crate::InputValue { graphql_input_object!(@generate_to_input_value, $name, self, $fields) } } diff --git a/juniper/src/macros/scalar.rs b/juniper/src/macros/scalar.rs index 7a19c6e5..c1024703 100644 --- a/juniper/src/macros/scalar.rs +++ b/juniper/src/macros/scalar.rs @@ -51,7 +51,7 @@ macro_rules! graphql_scalar { // string or none). // // ( $resolve_selfvar, $resolve_body ): the "self" argument and body for the - // resolve() method on GraphQLType and the to() method on ToInputValue. + // resolve() method on GraphQLType and the to_input_value() method on ToInputValue. // // ( $fiv_arg, $fiv_result, $fiv_body ): the method argument, result type, // and body for the from() method on FromInputValue. @@ -88,8 +88,8 @@ macro_rules! graphql_scalar { } impl $crate::ToInputValue for $name { - fn to(&$resolve_selfvar) -> $crate::InputValue { - $crate::ToInputValue::to(&$resolve_body) + fn to_input_value(&$resolve_selfvar) -> $crate::InputValue { + $crate::ToInputValue::to_input_value(&$resolve_body) } } diff --git a/juniper/src/types/containers.rs b/juniper/src/types/containers.rs index 3a53e8ba..64df1f70 100644 --- a/juniper/src/types/containers.rs +++ b/juniper/src/types/containers.rs @@ -52,9 +52,9 @@ impl ToInputValue for Option where T: ToInputValue, { - fn to(&self) -> InputValue { + fn to_input_value(&self) -> InputValue { match *self { - Some(ref v) => v.to(), + Some(ref v) => v.to_input_value(), None => InputValue::null(), } } @@ -117,8 +117,8 @@ impl ToInputValue for Vec where T: ToInputValue, { - fn to(&self) -> InputValue { - InputValue::list(self.iter().map(|v| v.to()).collect()) + fn to_input_value(&self) -> InputValue { + InputValue::list(self.iter().map(|v| v.to_input_value()).collect()) } } @@ -155,7 +155,7 @@ impl<'a, T> ToInputValue for &'a [T] where T: ToInputValue, { - fn to(&self) -> InputValue { - InputValue::list(self.iter().map(|v| v.to()).collect()) + fn to_input_value(&self) -> InputValue { + InputValue::list(self.iter().map(|v| v.to_input_value()).collect()) } } diff --git a/juniper/src/types/pointers.rs b/juniper/src/types/pointers.rs index 6e39ad68..ed4df3a2 100644 --- a/juniper/src/types/pointers.rs +++ b/juniper/src/types/pointers.rs @@ -66,8 +66,8 @@ impl ToInputValue for Box where T: ToInputValue, { - fn to(&self) -> InputValue { - (**self).to() + fn to_input_value(&self) -> InputValue { + (**self).to_input_value() } } @@ -120,7 +120,7 @@ impl<'a, T> ToInputValue for &'a T where T: ToInputValue, { - fn to(&self) -> InputValue { - (**self).to() + fn to_input_value(&self) -> InputValue { + (**self).to_input_value() } } diff --git a/juniper/src/types/scalars.rs b/juniper/src/types/scalars.rs index dbf228ba..48c23756 100644 --- a/juniper/src/types/scalars.rs +++ b/juniper/src/types/scalars.rs @@ -77,7 +77,7 @@ impl<'a> GraphQLType for &'a str { } impl<'a> ToInputValue for &'a str { - fn to(&self) -> InputValue { + fn to_input_value(&self) -> InputValue { InputValue::string(self) } } diff --git a/juniper/src/value.rs b/juniper/src/value.rs index 1ed0a02d..eaac620e 100644 --- a/juniper/src/value.rs +++ b/juniper/src/value.rs @@ -110,7 +110,7 @@ impl Value { } impl ToInputValue for Value { - fn to(&self) -> InputValue { + fn to_input_value(&self) -> InputValue { match *self { Value::Null => InputValue::Null, Value::Int(i) => InputValue::Int(i), @@ -118,12 +118,12 @@ impl ToInputValue for Value { Value::String(ref s) => InputValue::String(s.clone()), Value::Boolean(b) => InputValue::Boolean(b), Value::List(ref l) => { - InputValue::List(l.iter().map(|x| Spanning::unlocated(x.to())).collect()) + InputValue::List(l.iter().map(|x| Spanning::unlocated(x.to_input_value())).collect()) } Value::Object(ref o) => InputValue::Object( o.iter() .map(|(k, v)| { - (Spanning::unlocated(k.clone()), Spanning::unlocated(v.to())) + (Spanning::unlocated(k.clone()), Spanning::unlocated(v.to_input_value())) }) .collect(), ), diff --git a/juniper_codegen/src/derive_enum.rs b/juniper_codegen/src/derive_enum.rs index 238935b7..2b92844e 100644 --- a/juniper_codegen/src/derive_enum.rs +++ b/juniper_codegen/src/derive_enum.rs @@ -181,7 +181,7 @@ pub fn impl_enum(ast: &syn::DeriveInput) -> Tokens { } impl ::juniper::ToInputValue for #ident { - fn to(&self) -> ::juniper::InputValue { + fn to_input_value(&self) -> ::juniper::InputValue { match self { #(#to_inputs)* } diff --git a/juniper_codegen/src/derive_input_object.rs b/juniper_codegen/src/derive_input_object.rs index 6eff0cd4..469be09b 100644 --- a/juniper_codegen/src/derive_input_object.rs +++ b/juniper_codegen/src/derive_input_object.rs @@ -178,7 +178,7 @@ pub fn impl_input_object(ast: &syn::DeriveInput) -> Tokens { // Build to_input clause. let to_input = quote!{ - (#name, self.#field_ident.to()), + (#name, self.#field_ident.to_input_value()), }; to_inputs.push(to_input); } @@ -217,7 +217,7 @@ pub fn impl_input_object(ast: &syn::DeriveInput) -> Tokens { } impl ::juniper::ToInputValue for #ident { - fn to(&self) -> ::juniper::InputValue { + fn to_input_value(&self) -> ::juniper::InputValue { ::juniper::InputValue::object(vec![ #(#to_inputs)* ].into_iter().collect()) diff --git a/juniper_tests/src/codegen/derive_enum.rs b/juniper_tests/src/codegen/derive_enum.rs index c808b61d..63c04d53 100644 --- a/juniper_tests/src/codegen/derive_enum.rs +++ b/juniper_tests/src/codegen/derive_enum.rs @@ -26,14 +26,14 @@ fn test_derived_enum() { assert_eq!(meta.description(), Some(&"enum descr".to_string())); // Test Regular variant. - assert_eq!(SomeEnum::Regular.to(), InputValue::String("REGULAR".into())); + assert_eq!(SomeEnum::Regular.to_input_value(), InputValue::String("REGULAR".into())); assert_eq!( FromInputValue::from_input_value(&InputValue::String("REGULAR".into())), Some(SomeEnum::Regular) ); // Test FULL variant. - assert_eq!(SomeEnum::Full.to(), InputValue::String("FULL".into())); + assert_eq!(SomeEnum::Full.to_input_value(), InputValue::String("FULL".into())); assert_eq!( FromInputValue::from_input_value(&InputValue::String("FULL".into())), Some(SomeEnum::Full) diff --git a/juniper_tests/src/codegen/derive_input_object.rs b/juniper_tests/src/codegen/derive_input_object.rs index f3984d88..c275c563 100644 --- a/juniper_tests/src/codegen/derive_input_object.rs +++ b/juniper_tests/src/codegen/derive_input_object.rs @@ -26,6 +26,6 @@ fn test_derived_input_object() { regular_field: "a".to_string(), c: 33, }; - let restored: Input = FromInputValue::from_input_value(&obj.to()).unwrap(); + let restored: Input = FromInputValue::from_input_value(&obj.to_input_value()).unwrap(); assert_eq!(obj, restored); }