(
f: &mut std::fmt::Formatter<'_>,
typename: &str,
fields: &IndexMap<String, RValue>,
width: usize,
pretty: bool,
)
| 600 | } |
| 601 | |
| 602 | fn print_hashmap( |
| 603 | f: &mut std::fmt::Formatter<'_>, |
| 604 | typename: &str, |
| 605 | fields: &IndexMap<String, RValue>, |
| 606 | width: usize, |
| 607 | pretty: bool, |
| 608 | ) -> std::fmt::Result { |
| 609 | let items = match fields.get("items").unwrap() { |
| 610 | RValue::Array { data, .. } => data, |
| 611 | _ => { |
| 612 | write!(f, "{}", typename)?; |
| 613 | return print_struct(f, typename, fields, width, pretty); |
| 614 | } |
| 615 | }; |
| 616 | |
| 617 | let nl = if pretty { "\n" } else { "" }; |
| 618 | let indent = if pretty { |
| 619 | String::from_utf8(vec![b' '; width * 4]).unwrap() |
| 620 | } else { |
| 621 | String::new() |
| 622 | }; |
| 623 | write!(f, "{}[{}", indent, nl)?; |
| 624 | for (i, value) in items.iter().enumerate() { |
| 625 | if pretty { |
| 626 | write!( |
| 627 | f, |
| 628 | " {}{:#width$}{}{}", |
| 629 | indent, |
| 630 | value, |
| 631 | ",", |
| 632 | nl, |
| 633 | width = (width + 1) |
| 634 | )?; |
| 635 | } else { |
| 636 | write!( |
| 637 | f, |
| 638 | "{}{}", |
| 639 | value, |
| 640 | if i < items.len() - 1 { ", " } else { "" } |
| 641 | )?; |
| 642 | } |
| 643 | } |
| 644 | write!(f, "{}]{}", indent, nl)?; |
| 645 | write!(f, ".into_iter(){}", nl)?; |
| 646 | write!(f, ".collect::<{}>()", typename.replace(STD_HASH_STATE, ">"))?; |
| 647 | Ok(()) |
| 648 | } |
| 649 | |
| 650 | fn print_os_string( |
| 651 | f: &mut std::fmt::Formatter<'_>, |
no test coverage detected