@@ -8,7 +8,7 @@ use indexmap::IndexMap;
88use crate :: {
99 executor:: Variables ,
1010 parser:: Spanning ,
11- value:: { DefaultScalarValue , Scalar , ScalarValue } ,
11+ value:: { DefaultScalarValue , Scalar , ScalarValue , ToScalarValue } ,
1212} ;
1313
1414/// Type literal in a syntax tree.
@@ -243,7 +243,7 @@ impl<S> InputValue<S> {
243243 Self :: Null
244244 }
245245
246- /// Construct a scalar value
246+ /// Construct a scalar value.
247247 pub fn scalar < T : Into < S > > ( v : T ) -> Self {
248248 Self :: Scalar ( v. into ( ) )
249249 }
@@ -498,81 +498,79 @@ where
498498 }
499499}
500500
501- impl < S > IntoInputValue < S > for & str
501+ impl < T , S > IntoInputValue < S > for & T
502502where
503- String : Into < S > ,
503+ T : ToScalarValue < S > + ? Sized ,
504504{
505505 fn into_input_value ( self ) -> InputValue < S > {
506- InputValue :: scalar ( self . to_owned ( ) )
506+ InputValue :: Scalar ( self . to_scalar_value ( ) )
507507 }
508508}
509509
510- impl < S > IntoInputValue < S > for Cow < ' _ , str >
510+ impl < S > IntoInputValue < S > for String
511511where
512512 String : Into < S > ,
513513{
514514 fn into_input_value ( self ) -> InputValue < S > {
515- InputValue :: scalar ( self . into_owned ( ) )
515+ InputValue :: Scalar ( self . into ( ) )
516516 }
517517}
518518
519- impl < S > IntoInputValue < S > for String
519+ impl < S > IntoInputValue < S > for Cow < ' _ , str >
520520where
521- String : Into < S > ,
521+ for < ' a > & ' a str : IntoInputValue < S > ,
522+ String : IntoInputValue < S > ,
522523{
523524 fn into_input_value ( self ) -> InputValue < S > {
524- InputValue :: scalar ( self )
525- }
526- }
527-
528- impl < S : ScalarValue > IntoInputValue < S > for & ArcStr {
529- fn into_input_value ( self ) -> InputValue < S > {
530- InputValue :: scalar ( S :: from_displayable ( self ) )
531- }
532- }
533-
534- impl < S : ScalarValue > IntoInputValue < S > for ArcStr {
535- fn into_input_value ( self ) -> InputValue < S > {
536- ( & self ) . into_input_value ( )
525+ match self {
526+ Cow :: Borrowed ( s) => s. into_input_value ( ) ,
527+ Cow :: Owned ( s) => s. into_input_value ( ) ,
528+ }
537529 }
538530}
539531
540- impl < S : ScalarValue > IntoInputValue < S > for & CompactString {
532+ impl < S : ScalarValue > IntoInputValue < S > for ArcStr
533+ where
534+ ArcStr : ToScalarValue < S > ,
535+ {
541536 fn into_input_value ( self ) -> InputValue < S > {
542- InputValue :: scalar ( S :: from_displayable ( self ) )
537+ InputValue :: Scalar ( self . to_scalar_value ( ) )
543538 }
544539}
545540
546- impl < S : ScalarValue > IntoInputValue < S > for CompactString {
541+ impl < S : ScalarValue > IntoInputValue < S > for CompactString
542+ where
543+ CompactString : ToScalarValue < S > ,
544+ {
547545 fn into_input_value ( self ) -> InputValue < S > {
548- ( & self ) . into_input_value ( )
546+ InputValue :: Scalar ( self . to_scalar_value ( ) )
549547 }
550548}
551549
552550impl < S > IntoInputValue < S > for i32
553551where
554- i32 : Into < S > ,
552+ i32 : ToScalarValue < S > ,
555553{
556554 fn into_input_value ( self ) -> InputValue < S > {
557- InputValue :: scalar ( self )
555+ InputValue :: Scalar ( self . to_scalar_value ( ) )
558556 }
559557}
560558
561559impl < S > IntoInputValue < S > for f64
562560where
563- f64 : Into < S > ,
561+ f64 : ToScalarValue < S > ,
564562{
565563 fn into_input_value ( self ) -> InputValue < S > {
566- InputValue :: scalar ( self )
564+ InputValue :: Scalar ( self . to_scalar_value ( ) )
567565 }
568566}
569567
570568impl < S > IntoInputValue < S > for bool
571569where
572- bool : Into < S > ,
570+ bool : ToScalarValue < S > ,
573571{
574572 fn into_input_value ( self ) -> InputValue < S > {
575- InputValue :: scalar ( self )
573+ InputValue :: Scalar ( self . to_scalar_value ( ) )
576574 }
577575}
578576
0 commit comments