File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,26 @@ pub enum Value<'a, T: Text<'a>> {
58
58
Object ( BTreeMap < T :: Value , Value < ' a , T > > ) ,
59
59
}
60
60
61
+ impl < ' a , T : Text < ' a > > Value < ' a , T > {
62
+ pub fn into_static ( & self ) -> Value < ' static , String > {
63
+ match self {
64
+ Self :: Variable ( v) => Value :: Variable ( v. as_ref ( ) . into ( ) ) ,
65
+ Self :: Int ( i) => Value :: Int ( i. clone ( ) ) ,
66
+ Self :: Float ( f) => Value :: Float ( * f) ,
67
+ Self :: String ( s) => Value :: String ( s. clone ( ) ) ,
68
+ Self :: Boolean ( b) => Value :: Boolean ( * b) ,
69
+ Self :: Null => Value :: Null ,
70
+ Self :: Enum ( v) => Value :: Enum ( v. as_ref ( ) . into ( ) ) ,
71
+ Self :: List ( l) => {
72
+ Value :: List ( l. iter ( ) . map ( |e| e. into_static ( ) ) . collect ( ) )
73
+ } ,
74
+ Self :: Object ( o) => {
75
+ Value :: Object ( o. iter ( ) . map ( |( k, v) | ( k. as_ref ( ) . into ( ) , v. into_static ( ) ) ) . collect ( ) )
76
+ } ,
77
+ }
78
+ }
79
+ }
80
+
61
81
#[ derive( Debug , Clone , PartialEq ) ]
62
82
pub enum Type < ' a , T : Text < ' a > > {
63
83
NamedType ( T :: Value ) ,
You can’t perform that action at this time.
0 commit comments