Skip to content

Commit c1d44da

Browse files
committed
fix: run cargo-fmt
1 parent e36c085 commit c1d44da

File tree

1 file changed

+98
-17
lines changed

1 file changed

+98
-17
lines changed

rust/src/lib.rs

Lines changed: 98 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,19 @@ fn convert_string(key: &str, val: &str, config: &ConvertConfig) -> PyResult<Stri
182182
escape_xml(val)
183183
};
184184

185-
Ok(format!("<{}{}>{}</{}>", xml_key, attr_string, content, xml_key))
185+
Ok(format!(
186+
"<{}{}>{}</{}>",
187+
xml_key, attr_string, content, xml_key
188+
))
186189
}
187190

188191
/// Convert a number value to XML
189-
fn convert_number(key: &str, val: &str, type_name: &str, config: &ConvertConfig) -> PyResult<String> {
192+
fn convert_number(
193+
key: &str,
194+
val: &str,
195+
type_name: &str,
196+
config: &ConvertConfig,
197+
) -> PyResult<String> {
190198
let (xml_key, name_attr) = make_valid_xml_name(key);
191199
let mut attrs = Vec::new();
192200

@@ -215,7 +223,10 @@ fn convert_bool(key: &str, val: bool, config: &ConvertConfig) -> PyResult<String
215223

216224
let attr_string = make_attr_string(&attrs);
217225
let bool_str = if val { "true" } else { "false" };
218-
Ok(format!("<{}{}>{}</{}>", xml_key, attr_string, bool_str, xml_key))
226+
Ok(format!(
227+
"<{}{}>{}</{}>",
228+
xml_key, attr_string, bool_str, xml_key
229+
))
219230
}
220231

221232
/// Convert a None value to XML
@@ -259,7 +270,12 @@ fn convert_dict(
259270
}
260271
let attr_string = make_attr_string(&attrs);
261272
let bool_str = if bool_val { "true" } else { "false" };
262-
write!(output, "<{}{}>{}</{}>", xml_key, attr_string, bool_str, xml_key).unwrap();
273+
write!(
274+
output,
275+
"<{}{}>{}</{}>",
276+
xml_key, attr_string, bool_str, xml_key
277+
)
278+
.unwrap();
263279
}
264280
// Handle int
265281
else if val.is_instance_of::<PyInt>() {
@@ -272,7 +288,12 @@ fn convert_dict(
272288
attrs.push(("type".to_string(), "int".to_string()));
273289
}
274290
let attr_string = make_attr_string(&attrs);
275-
write!(output, "<{}{}>{}</{}>", xml_key, attr_string, int_val, xml_key).unwrap();
291+
write!(
292+
output,
293+
"<{}{}>{}</{}>",
294+
xml_key, attr_string, int_val, xml_key
295+
)
296+
.unwrap();
276297
}
277298
// Handle float
278299
else if val.is_instance_of::<PyFloat>() {
@@ -285,7 +306,12 @@ fn convert_dict(
285306
attrs.push(("type".to_string(), "float".to_string()));
286307
}
287308
let attr_string = make_attr_string(&attrs);
288-
write!(output, "<{}{}>{}</{}>", xml_key, attr_string, float_val, xml_key).unwrap();
309+
write!(
310+
output,
311+
"<{}{}>{}</{}>",
312+
xml_key, attr_string, float_val, xml_key
313+
)
314+
.unwrap();
289315
}
290316
// Handle string
291317
else if val.is_instance_of::<PyString>() {
@@ -303,7 +329,12 @@ fn convert_dict(
303329
} else {
304330
escape_xml(&str_val)
305331
};
306-
write!(output, "<{}{}>{}</{}>", xml_key, attr_string, content, xml_key).unwrap();
332+
write!(
333+
output,
334+
"<{}{}>{}</{}>",
335+
xml_key, attr_string, content, xml_key
336+
)
337+
.unwrap();
307338
}
308339
// Handle None
309340
else if val.is_none() {
@@ -329,7 +360,12 @@ fn convert_dict(
329360
}
330361
let attr_string = make_attr_string(&attrs);
331362
let inner = convert_dict(py, nested_dict, &xml_key, config)?;
332-
write!(output, "<{}{}>{}</{}>", xml_key, attr_string, inner, xml_key).unwrap();
363+
write!(
364+
output,
365+
"<{}{}>{}</{}>",
366+
xml_key, attr_string, inner, xml_key
367+
)
368+
.unwrap();
333369
}
334370
// Handle list
335371
else if val.is_instance_of::<PyList>() {
@@ -345,7 +381,12 @@ fn convert_dict(
345381
attrs.push(("type".to_string(), "list".to_string()));
346382
}
347383
let attr_string = make_attr_string(&attrs);
348-
write!(output, "<{}{}>{}</{}>", xml_key, attr_string, list_output, xml_key).unwrap();
384+
write!(
385+
output,
386+
"<{}{}>{}</{}>",
387+
xml_key, attr_string, list_output, xml_key
388+
)
389+
.unwrap();
349390
} else {
350391
output.push_str(&list_output);
351392
}
@@ -366,7 +407,12 @@ fn convert_dict(
366407
} else {
367408
escape_xml(&str_val)
368409
};
369-
write!(output, "<{}{}>{}</{}>", xml_key, attr_string, content, xml_key).unwrap();
410+
write!(
411+
output,
412+
"<{}{}>{}</{}>",
413+
xml_key, attr_string, content, xml_key
414+
)
415+
.unwrap();
370416
}
371417
}
372418

@@ -403,7 +449,12 @@ fn convert_list(
403449
}
404450
let attr_string = make_attr_string(&attrs);
405451
let bool_str = if bool_val { "true" } else { "false" };
406-
write!(output, "<{}{}>{}</{}>", tag_name, attr_string, bool_str, tag_name).unwrap();
452+
write!(
453+
output,
454+
"<{}{}>{}</{}>",
455+
tag_name, attr_string, bool_str, tag_name
456+
)
457+
.unwrap();
407458
}
408459
// Handle int
409460
else if item.is_instance_of::<PyInt>() {
@@ -413,7 +464,12 @@ fn convert_list(
413464
attrs.push(("type".to_string(), "int".to_string()));
414465
}
415466
let attr_string = make_attr_string(&attrs);
416-
write!(output, "<{}{}>{}</{}>", tag_name, attr_string, int_val, tag_name).unwrap();
467+
write!(
468+
output,
469+
"<{}{}>{}</{}>",
470+
tag_name, attr_string, int_val, tag_name
471+
)
472+
.unwrap();
417473
}
418474
// Handle float
419475
else if item.is_instance_of::<PyFloat>() {
@@ -423,7 +479,12 @@ fn convert_list(
423479
attrs.push(("type".to_string(), "float".to_string()));
424480
}
425481
let attr_string = make_attr_string(&attrs);
426-
write!(output, "<{}{}>{}</{}>", tag_name, attr_string, float_val, tag_name).unwrap();
482+
write!(
483+
output,
484+
"<{}{}>{}</{}>",
485+
tag_name, attr_string, float_val, tag_name
486+
)
487+
.unwrap();
427488
}
428489
// Handle string
429490
else if item.is_instance_of::<PyString>() {
@@ -438,7 +499,12 @@ fn convert_list(
438499
} else {
439500
escape_xml(&str_val)
440501
};
441-
write!(output, "<{}{}>{}</{}>", tag_name, attr_string, content, tag_name).unwrap();
502+
write!(
503+
output,
504+
"<{}{}>{}</{}>",
505+
tag_name, attr_string, content, tag_name
506+
)
507+
.unwrap();
442508
}
443509
// Handle None
444510
else if item.is_none() {
@@ -460,7 +526,12 @@ fn convert_list(
460526
attrs.push(("type".to_string(), "dict".to_string()));
461527
}
462528
let attr_string = make_attr_string(&attrs);
463-
write!(output, "<{}{}>{}</{}>", tag_name, attr_string, inner, tag_name).unwrap();
529+
write!(
530+
output,
531+
"<{}{}>{}</{}>",
532+
tag_name, attr_string, inner, tag_name
533+
)
534+
.unwrap();
464535
} else {
465536
output.push_str(&inner);
466537
}
@@ -475,7 +546,12 @@ fn convert_list(
475546
attrs.push(("type".to_string(), "list".to_string()));
476547
}
477548
let attr_string = make_attr_string(&attrs);
478-
write!(output, "<{}{}>{}</{}>", tag_name, attr_string, inner, tag_name).unwrap();
549+
write!(
550+
output,
551+
"<{}{}>{}</{}>",
552+
tag_name, attr_string, inner, tag_name
553+
)
554+
.unwrap();
479555
}
480556
// Fallback
481557
else {
@@ -490,7 +566,12 @@ fn convert_list(
490566
} else {
491567
escape_xml(&str_val)
492568
};
493-
write!(output, "<{}{}>{}</{}>", tag_name, attr_string, content, tag_name).unwrap();
569+
write!(
570+
output,
571+
"<{}{}>{}</{}>",
572+
tag_name, attr_string, content, tag_name
573+
)
574+
.unwrap();
494575
}
495576
}
496577

0 commit comments

Comments
 (0)