@@ -156,34 +156,33 @@ impl KValue {
156156 /// Returns the value's type as a [KString]
157157 pub fn type_as_string ( & self ) -> KString {
158158 use KValue :: * ;
159+
159160 match & self {
160- Null => TYPE_NULL . with ( |x| x . clone ( ) ) ,
161- Bool ( _) => TYPE_BOOL . with ( |x| x . clone ( ) ) ,
162- Number ( _) => TYPE_NUMBER . with ( |x| x . clone ( ) ) ,
163- List ( _) => TYPE_LIST . with ( |x| x . clone ( ) ) ,
164- Range { .. } => TYPE_RANGE . with ( |x| x . clone ( ) ) ,
161+ Null => "Null" . into ( ) ,
162+ Bool ( _) => "Bool" . into ( ) ,
163+ Number ( _) => "Number" . into ( ) ,
164+ List ( _) => "List" . into ( ) ,
165+ Range { .. } => "Range" . into ( ) ,
165166 Map ( m) if m. meta_map ( ) . is_some ( ) => match m. get_meta_value ( & MetaKey :: Type ) {
166167 Some ( Str ( s) ) => s,
167168 Some ( _) => "Error: expected string as result of @type" . into ( ) ,
168169 None => match m. get_meta_value ( & MetaKey :: Base ) {
169170 Some ( base @ Map ( _) ) => base. type_as_string ( ) ,
170- _ => TYPE_OBJECT . with ( |x| x . clone ( ) ) ,
171+ _ => "Object" . into ( ) ,
171172 } ,
172173 } ,
173- Map ( _) => TYPE_MAP . with ( |x| x. clone ( ) ) ,
174- Str ( _) => TYPE_STRING . with ( |x| x. clone ( ) ) ,
175- Tuple ( _) => TYPE_TUPLE . with ( |x| x. clone ( ) ) ,
176- Function ( f) if f. generator => TYPE_GENERATOR . with ( |x| x. clone ( ) ) ,
177- CaptureFunction ( f) if f. info . generator => TYPE_GENERATOR . with ( |x| x. clone ( ) ) ,
178- Function ( _) | CaptureFunction ( _) | NativeFunction ( _) => {
179- TYPE_FUNCTION . with ( |x| x. clone ( ) )
180- }
174+ Map ( _) => "Map" . into ( ) ,
175+ Str ( _) => "String" . into ( ) ,
176+ Tuple ( _) => "Tuple" . into ( ) ,
177+ Function ( f) if f. generator => "Generator" . into ( ) ,
178+ CaptureFunction ( f) if f. info . generator => "Generator" . into ( ) ,
179+ Function ( _) | CaptureFunction ( _) | NativeFunction ( _) => "Function" . into ( ) ,
181180 Object ( o) => o. try_borrow ( ) . map_or_else (
182181 |_| "Error: object already borrowed" . into ( ) ,
183182 |o| o. type_string ( ) ,
184183 ) ,
185- Iterator ( _) => TYPE_ITERATOR . with ( |x| x . clone ( ) ) ,
186- TemporaryTuple { .. } => TYPE_TEMPORARY_TUPLE . with ( |x| x . clone ( ) ) ,
184+ Iterator ( _) => "Iterator" . into ( ) ,
185+ TemporaryTuple { .. } => "Temporary_tuple" . into ( ) ,
187186 }
188187 }
189188
@@ -215,22 +214,6 @@ impl KValue {
215214 }
216215}
217216
218- thread_local ! {
219- static TYPE_NULL : KString = "Null" . into( ) ;
220- static TYPE_BOOL : KString = "Bool" . into( ) ;
221- static TYPE_NUMBER : KString = "Number" . into( ) ;
222- static TYPE_LIST : KString = "List" . into( ) ;
223- static TYPE_RANGE : KString = "Range" . into( ) ;
224- static TYPE_MAP : KString = "Map" . into( ) ;
225- static TYPE_OBJECT : KString = "Object" . into( ) ;
226- static TYPE_STRING : KString = "String" . into( ) ;
227- static TYPE_TUPLE : KString = "Tuple" . into( ) ;
228- static TYPE_FUNCTION : KString = "Function" . into( ) ;
229- static TYPE_GENERATOR : KString = "Generator" . into( ) ;
230- static TYPE_ITERATOR : KString = "Iterator" . into( ) ;
231- static TYPE_TEMPORARY_TUPLE : KString = "TemporaryTuple" . into( ) ;
232- }
233-
234217impl fmt:: Debug for KValue {
235218 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
236219 write ! ( f, "{}" , self . type_as_string( ) )
0 commit comments