@@ -54,7 +54,7 @@ use std::str;
5454
5555use derive_more:: with_trait:: { Debug , Display , Error , Into } ;
5656
57- use crate :: { InputValue , ScalarValue , Value , graphql_scalar} ;
57+ use crate :: { ScalarValue , Value , graphql_scalar} ;
5858
5959/// Representation of a civil date in the Gregorian calendar.
6060///
@@ -90,12 +90,9 @@ mod local_date {
9090 Value :: scalar ( v. strftime ( FORMAT ) . to_string ( ) )
9191 }
9292
93- pub ( super ) fn from_input < S > ( v : & InputValue < S > ) -> Result < LocalDate , String >
94- where
95- S : ScalarValue ,
96- {
97- v. as_string_value ( )
98- . ok_or_else ( || format ! ( "Expected `String`, found: {v}" ) )
93+ pub ( super ) fn from_input ( s : & impl ScalarValue ) -> Result < LocalDate , String > {
94+ s. as_str ( )
95+ . ok_or_else ( || format ! ( "Expected `String`, found: {s}" ) )
9996 . and_then ( |s| {
10097 LocalDate :: strptime ( FORMAT , s) . map_err ( |e| format ! ( "Invalid `LocalDate`: {e}" ) )
10198 } )
@@ -153,12 +150,9 @@ mod local_time {
153150 )
154151 }
155152
156- pub ( super ) fn from_input < S > ( v : & InputValue < S > ) -> Result < LocalTime , String >
157- where
158- S : ScalarValue ,
159- {
160- v. as_string_value ( )
161- . ok_or_else ( || format ! ( "Expected `String`, found: {v}" ) )
153+ pub ( super ) fn from_input ( s : & impl ScalarValue ) -> Result < LocalTime , String > {
154+ s. as_str ( )
155+ . ok_or_else ( || format ! ( "Expected `String`, found: {s}" ) )
162156 . and_then ( |s| {
163157 // First, try to parse the most used format.
164158 // At the end, try to parse the full format for the parsing
@@ -207,12 +201,9 @@ mod local_date_time {
207201 Value :: scalar ( v. strftime ( FORMAT ) . to_string ( ) )
208202 }
209203
210- pub ( super ) fn from_input < S > ( v : & InputValue < S > ) -> Result < LocalDateTime , String >
211- where
212- S : ScalarValue ,
213- {
214- v. as_string_value ( )
215- . ok_or_else ( || format ! ( "Expected `String`, found: {v}" ) )
204+ pub ( super ) fn from_input ( s : & impl ScalarValue ) -> Result < LocalDateTime , String > {
205+ s. as_str ( )
206+ . ok_or_else ( || format ! ( "Expected `String`, found: {s}" ) )
216207 . and_then ( |s| {
217208 LocalDateTime :: strptime ( FORMAT , s)
218209 . map_err ( |e| format ! ( "Invalid `LocalDateTime`: {e}" ) )
@@ -254,12 +245,9 @@ mod date_time {
254245 Value :: scalar ( v. strftime ( FORMAT ) . to_string ( ) )
255246 }
256247
257- pub ( super ) fn from_input < S > ( v : & InputValue < S > ) -> Result < DateTime , String >
258- where
259- S : ScalarValue ,
260- {
261- v. as_string_value ( )
262- . ok_or_else ( || format ! ( "Expected `String`, found: {v}" ) )
248+ pub ( super ) fn from_input ( s : & impl ScalarValue ) -> Result < DateTime , String > {
249+ s. as_str ( )
250+ . ok_or_else ( || format ! ( "Expected `String`, found: {s}" ) )
263251 . and_then ( |s| DateTime :: from_str ( s) . map_err ( |e| format ! ( "Invalid `DateTime`: {e}" ) ) )
264252 }
265253}
@@ -299,12 +287,9 @@ mod zoned_date_time {
299287 Value :: scalar ( v. to_string ( ) )
300288 }
301289
302- pub ( super ) fn from_input < S > ( v : & InputValue < S > ) -> Result < ZonedDateTime , String >
303- where
304- S : ScalarValue ,
305- {
306- v. as_string_value ( )
307- . ok_or_else ( || format ! ( "Expected `String`, found: {v}" ) )
290+ pub ( super ) fn from_input ( s : & impl ScalarValue ) -> Result < ZonedDateTime , String > {
291+ s. as_str ( )
292+ . ok_or_else ( || format ! ( "Expected `String`, found: {s}" ) )
308293 . and_then ( |s| {
309294 ZonedDateTime :: from_str ( s) . map_err ( |e| format ! ( "Invalid `ZonedDateTime`: {e}" ) )
310295 } )
@@ -341,12 +326,9 @@ mod duration {
341326 Value :: scalar ( v. to_string ( ) )
342327 }
343328
344- pub ( super ) fn from_input < S > ( v : & InputValue < S > ) -> Result < Duration , String >
345- where
346- S : ScalarValue ,
347- {
348- v. as_string_value ( )
349- . ok_or_else ( || format ! ( "Expected `String`, found: {v}" ) )
329+ pub ( super ) fn from_input ( s : & impl ScalarValue ) -> Result < Duration , String > {
330+ s. as_str ( )
331+ . ok_or_else ( || format ! ( "Expected `String`, found: {s}" ) )
350332 . and_then ( |s| Duration :: from_str ( s) . map_err ( |e| format ! ( "Invalid `Duration`: {e}" ) ) )
351333 }
352334}
@@ -395,12 +377,9 @@ mod time_zone_or_utc_offset {
395377 ) )
396378 }
397379
398- pub ( super ) fn from_input < S > ( v : & InputValue < S > ) -> Result < TimeZoneOrUtcOffset , String >
399- where
400- S : ScalarValue ,
401- {
402- v. as_string_value ( )
403- . ok_or_else ( || format ! ( "Expected `String`, found: {v}" ) )
380+ pub ( super ) fn from_input ( s : & impl ScalarValue ) -> Result < TimeZoneOrUtcOffset , String > {
381+ s. as_str ( )
382+ . ok_or_else ( || format ! ( "Expected `String`, found: {s}" ) )
404383 . and_then ( |s| {
405384 TimeZoneOrUtcOffset :: get ( s)
406385 . map_err ( TimeZoneParsingError :: InvalidTimeZone )
@@ -478,12 +457,9 @@ mod time_zone {
478457 Value :: scalar ( v. to_string ( ) )
479458 }
480459
481- pub ( super ) fn from_input < S > ( v : & InputValue < S > ) -> Result < TimeZone , String >
482- where
483- S : ScalarValue ,
484- {
485- v. as_string_value ( )
486- . ok_or_else ( || format ! ( "Expected `String`, found: {v}" ) )
460+ pub ( super ) fn from_input ( s : & impl ScalarValue ) -> Result < TimeZone , String > {
461+ s. as_str ( )
462+ . ok_or_else ( || format ! ( "Expected `String`, found: {s}" ) )
487463 . and_then ( |s| s. parse ( ) . map_err ( |e| format ! ( "Invalid `TimeZone`: {e}" ) ) )
488464 }
489465}
@@ -531,12 +507,9 @@ mod utc_offset {
531507 Value :: scalar ( buf)
532508 }
533509
534- pub ( super ) fn from_input < S > ( v : & InputValue < S > ) -> Result < UtcOffset , String >
535- where
536- S : ScalarValue ,
537- {
538- v. as_string_value ( )
539- . ok_or_else ( || format ! ( "Expected `String`, found: {v}" ) )
510+ pub ( super ) fn from_input ( s : & impl ScalarValue ) -> Result < UtcOffset , String > {
511+ s. as_str ( )
512+ . ok_or_else ( || format ! ( "Expected `String`, found: {s}" ) )
540513 . and_then ( |s| utc_offset_from_str ( s) . map_err ( |e| format ! ( "Invalid `UtcOffset`: {e}" ) ) )
541514 }
542515}
0 commit comments