File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 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>> {
5858 Object ( BTreeMap < T :: Value , Value < ' a , T > > ) ,
5959}
6060
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+
6181#[ derive( Debug , Clone , PartialEq ) ]
6282pub enum Type < ' a , T : Text < ' a > > {
6383 NamedType ( T :: Value ) ,
You can’t perform that action at this time.
0 commit comments