@@ -47,33 +47,33 @@ impl Display for Value {
4747 }
4848}
4949
50- struct TargetSpec ( Object ) ;
51-
52- impl TargetSpec {
53- fn new ( ) -> TargetSpec {
54- TargetSpec ( Vec :: new ( ) )
50+ impl From < bool > for Value {
51+ fn from ( value : bool ) -> Self {
52+ Self :: Boolean ( value)
5553 }
5654}
5755
58- trait Push < T > {
59- fn push ( & mut self , key : & str , value : T ) ;
56+ impl From < i32 > for Value {
57+ fn from ( value : i32 ) -> Self {
58+ Self :: Number ( value)
59+ }
6060}
6161
62- impl Push < bool > for TargetSpec {
63- fn push ( & mut self , key : & str , value : bool ) {
64- self . 0 . push ( ( key . to_string ( ) , Value :: Boolean ( value) ) ) ;
62+ impl From < String > for Value {
63+ fn from ( value : String ) -> Self {
64+ Self :: String ( value)
6565 }
6666}
6767
68- impl Push < i32 > for TargetSpec {
69- fn push ( & mut self , key : & str , value : i32 ) {
70- self . 0 . push ( ( key . to_string ( ) , Value :: Number ( value ) ) ) ;
68+ impl From < & str > for Value {
69+ fn from ( value : & str ) -> Self {
70+ Self :: String ( value . to_string ( ) )
7171 }
7272}
7373
74- impl Push < String > for TargetSpec {
75- fn push ( & mut self , key : & str , value : String ) {
76- self . 0 . push ( ( key . to_string ( ) , Value :: String ( value ) ) ) ;
74+ impl From < Object > for Value {
75+ fn from ( object : Object ) -> Self {
76+ Self :: Object ( object )
7777 }
7878}
7979
@@ -83,9 +83,15 @@ impl Push<&str> for TargetSpec {
8383 }
8484}
8585
86- impl Push < Object > for TargetSpec {
87- fn push ( & mut self , key : & str , value : Object ) {
88- self . 0 . push ( ( key. to_string ( ) , Value :: Object ( value) ) ) ;
86+ struct TargetSpec ( Object ) ;
87+
88+ impl TargetSpec {
89+ fn new ( ) -> TargetSpec {
90+ TargetSpec ( Vec :: new ( ) )
91+ }
92+
93+ fn push ( & mut self , key : & str , value : impl Into < Value > ) {
94+ self . 0 . push ( ( key. to_string ( ) , value. into ( ) ) ) ;
8995 }
9096}
9197
0 commit comments