@@ -8,7 +8,7 @@ use indexmap::IndexMap;
8
8
use crate :: {
9
9
executor:: Variables ,
10
10
parser:: Spanning ,
11
- value:: { DefaultScalarValue , Scalar , ScalarValue } ,
11
+ value:: { DefaultScalarValue , Scalar , ScalarValue , ToScalarValue } ,
12
12
} ;
13
13
14
14
/// Type literal in a syntax tree.
@@ -243,7 +243,7 @@ impl<S> InputValue<S> {
243
243
Self :: Null
244
244
}
245
245
246
- /// Construct a scalar value
246
+ /// Construct a scalar value.
247
247
pub fn scalar < T : Into < S > > ( v : T ) -> Self {
248
248
Self :: Scalar ( v. into ( ) )
249
249
}
@@ -498,81 +498,79 @@ where
498
498
}
499
499
}
500
500
501
- impl < S > IntoInputValue < S > for & str
501
+ impl < T , S > IntoInputValue < S > for & T
502
502
where
503
- String : Into < S > ,
503
+ T : ToScalarValue < S > + ? Sized ,
504
504
{
505
505
fn into_input_value ( self ) -> InputValue < S > {
506
- InputValue :: scalar ( self . to_owned ( ) )
506
+ InputValue :: Scalar ( self . to_scalar_value ( ) )
507
507
}
508
508
}
509
509
510
- impl < S > IntoInputValue < S > for Cow < ' _ , str >
510
+ impl < S > IntoInputValue < S > for String
511
511
where
512
512
String : Into < S > ,
513
513
{
514
514
fn into_input_value ( self ) -> InputValue < S > {
515
- InputValue :: scalar ( self . into_owned ( ) )
515
+ InputValue :: Scalar ( self . into ( ) )
516
516
}
517
517
}
518
518
519
- impl < S > IntoInputValue < S > for String
519
+ impl < S > IntoInputValue < S > for Cow < ' _ , str >
520
520
where
521
- String : Into < S > ,
521
+ for < ' a > & ' a str : IntoInputValue < S > ,
522
+ String : IntoInputValue < S > ,
522
523
{
523
524
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
+ }
537
529
}
538
530
}
539
531
540
- impl < S : ScalarValue > IntoInputValue < S > for & CompactString {
532
+ impl < S : ScalarValue > IntoInputValue < S > for ArcStr
533
+ where
534
+ ArcStr : ToScalarValue < S > ,
535
+ {
541
536
fn into_input_value ( self ) -> InputValue < S > {
542
- InputValue :: scalar ( S :: from_displayable ( self ) )
537
+ InputValue :: Scalar ( self . to_scalar_value ( ) )
543
538
}
544
539
}
545
540
546
- impl < S : ScalarValue > IntoInputValue < S > for CompactString {
541
+ impl < S : ScalarValue > IntoInputValue < S > for CompactString
542
+ where
543
+ CompactString : ToScalarValue < S > ,
544
+ {
547
545
fn into_input_value ( self ) -> InputValue < S > {
548
- ( & self ) . into_input_value ( )
546
+ InputValue :: Scalar ( self . to_scalar_value ( ) )
549
547
}
550
548
}
551
549
552
550
impl < S > IntoInputValue < S > for i32
553
551
where
554
- i32 : Into < S > ,
552
+ i32 : ToScalarValue < S > ,
555
553
{
556
554
fn into_input_value ( self ) -> InputValue < S > {
557
- InputValue :: scalar ( self )
555
+ InputValue :: Scalar ( self . to_scalar_value ( ) )
558
556
}
559
557
}
560
558
561
559
impl < S > IntoInputValue < S > for f64
562
560
where
563
- f64 : Into < S > ,
561
+ f64 : ToScalarValue < S > ,
564
562
{
565
563
fn into_input_value ( self ) -> InputValue < S > {
566
- InputValue :: scalar ( self )
564
+ InputValue :: Scalar ( self . to_scalar_value ( ) )
567
565
}
568
566
}
569
567
570
568
impl < S > IntoInputValue < S > for bool
571
569
where
572
- bool : Into < S > ,
570
+ bool : ToScalarValue < S > ,
573
571
{
574
572
fn into_input_value ( self ) -> InputValue < S > {
575
- InputValue :: scalar ( self )
573
+ InputValue :: Scalar ( self . to_scalar_value ( ) )
576
574
}
577
575
}
578
576
0 commit comments