@@ -32,32 +32,6 @@ fn wrap_cdata(s: &str) -> String {
3232 format ! ( "<![CDATA[{}]]>" , escaped)
3333}
3434
35- /// Get the XML type string for a Python value
36- fn get_xml_type ( obj : & Bound < ' _ , PyAny > ) -> & ' static str {
37- if obj. is_none ( ) {
38- "null"
39- } else if obj. is_instance_of :: < PyBool > ( ) {
40- "bool"
41- } else if obj. is_instance_of :: < PyInt > ( ) {
42- "int"
43- } else if obj. is_instance_of :: < PyFloat > ( ) {
44- "float"
45- } else if obj. is_instance_of :: < PyString > ( ) {
46- "str"
47- } else if obj. is_instance_of :: < PyDict > ( ) {
48- "dict"
49- } else if obj. is_instance_of :: < PyList > ( ) {
50- "list"
51- } else {
52- // Check for other sequences by trying to get length
53- if obj. len ( ) . is_ok ( ) {
54- "list"
55- } else {
56- "str"
57- }
58- }
59- }
60-
6135/// Check if a key is a valid XML element name (simplified check)
6236/// Full validation would require XML parsing, but this catches common issues
6337fn is_valid_xml_name ( key : & str ) -> bool {
@@ -167,13 +141,13 @@ fn convert_value(
167141
168142 // Handle dict
169143 if obj. is_instance_of :: < PyDict > ( ) {
170- let dict: & Bound < ' _ , PyDict > = obj. downcast ( ) ?;
144+ let dict: & Bound < ' _ , PyDict > = obj. cast ( ) ?;
171145 return convert_dict ( py, dict, parent, config) ;
172146 }
173147
174148 // Handle list
175149 if obj. is_instance_of :: < PyList > ( ) {
176- let list: & Bound < ' _ , PyList > = obj. downcast ( ) ?;
150+ let list: & Bound < ' _ , PyList > = obj. cast ( ) ?;
177151 return convert_list ( py, list, parent, config) ;
178152 }
179153
@@ -264,7 +238,7 @@ fn convert_none(key: &str, config: &ConvertConfig) -> PyResult<String> {
264238fn convert_dict (
265239 py : Python < ' _ > ,
266240 dict : & Bound < ' _ , PyDict > ,
267- parent : & str ,
241+ _parent : & str ,
268242 config : & ConvertConfig ,
269243) -> PyResult < String > {
270244 let mut output = String :: new ( ) ;
@@ -345,7 +319,7 @@ fn convert_dict(
345319 }
346320 // Handle nested dict
347321 else if val. is_instance_of :: < PyDict > ( ) {
348- let nested_dict: & Bound < ' _ , PyDict > = val. downcast ( ) ?;
322+ let nested_dict: & Bound < ' _ , PyDict > = val. cast ( ) ?;
349323 let mut attrs = Vec :: new ( ) ;
350324 if let Some ( ( k, v) ) = name_attr {
351325 attrs. push ( ( k, v) ) ;
@@ -359,7 +333,7 @@ fn convert_dict(
359333 }
360334 // Handle list
361335 else if val. is_instance_of :: < PyList > ( ) {
362- let list: & Bound < ' _ , PyList > = val. downcast ( ) ?;
336+ let list: & Bound < ' _ , PyList > = val. cast ( ) ?;
363337 let list_output = convert_list ( py, list, & xml_key, config) ?;
364338
365339 if config. item_wrap {
@@ -477,7 +451,7 @@ fn convert_list(
477451 }
478452 // Handle nested dict
479453 else if item. is_instance_of :: < PyDict > ( ) {
480- let nested_dict: & Bound < ' _ , PyDict > = item. downcast ( ) ?;
454+ let nested_dict: & Bound < ' _ , PyDict > = item. cast ( ) ?;
481455 let inner = convert_dict ( py, nested_dict, tag_name, config) ?;
482456
483457 if config. item_wrap || config. list_headers {
@@ -493,7 +467,7 @@ fn convert_list(
493467 }
494468 // Handle nested list
495469 else if item. is_instance_of :: < PyList > ( ) {
496- let nested_list: & Bound < ' _ , PyList > = item. downcast ( ) ?;
470+ let nested_list: & Bound < ' _ , PyList > = item. cast ( ) ?;
497471 let inner = convert_list ( py, nested_list, tag_name, config) ?;
498472
499473 let mut attrs = Vec :: new ( ) ;
@@ -558,10 +532,10 @@ fn dicttoxml(
558532 } ;
559533
560534 let content = if obj. is_instance_of :: < PyDict > ( ) {
561- let dict: & Bound < ' _ , PyDict > = obj. downcast ( ) ?;
535+ let dict: & Bound < ' _ , PyDict > = obj. cast ( ) ?;
562536 convert_dict ( py, dict, custom_root, & config) ?
563537 } else if obj. is_instance_of :: < PyList > ( ) {
564- let list: & Bound < ' _ , PyList > = obj. downcast ( ) ?;
538+ let list: & Bound < ' _ , PyList > = obj. cast ( ) ?;
565539 convert_list ( py, list, custom_root, & config) ?
566540 } else {
567541 convert_value ( py, obj, custom_root, & config, custom_root) ?
0 commit comments