(
f: &mut std::fmt::Formatter<'_>,
typename: &str,
fields: &IndexMap<String, RValue>,
width: usize,
pretty: bool,
)
| 528 | } |
| 529 | |
| 530 | fn print_struct( |
| 531 | f: &mut std::fmt::Formatter<'_>, |
| 532 | typename: &str, |
| 533 | fields: &IndexMap<String, RValue>, |
| 534 | width: usize, |
| 535 | pretty: bool, |
| 536 | ) -> std::fmt::Result { |
| 537 | if (typename.starts_with(CORE_REF_CELL) && fields.contains_key("value")) |
| 538 | || (typename.starts_with(STD_MUTEX) && fields.contains_key("data")) |
| 539 | || (typename.starts_with(STD_RWLOCK) && fields.contains_key("data")) |
| 540 | { |
| 541 | let mut value = fields |
| 542 | .get(if typename.starts_with(CORE_REF_CELL) { |
| 543 | "value" |
| 544 | } else { |
| 545 | "data" |
| 546 | }) |
| 547 | .unwrap(); |
| 548 | match value { |
| 549 | RValue::Struct { fields, .. } => { |
| 550 | if let Some(v) = fields.get("value") { |
| 551 | value = v; |
| 552 | } |
| 553 | } |
| 554 | _ => (), |
| 555 | } |
| 556 | write!(f, "::new(")?; |
| 557 | if pretty { |
| 558 | write!(f, "{}", value)?; |
| 559 | } else { |
| 560 | write!(f, "{:#width$}", value, width = width)?; |
| 561 | } |
| 562 | write!(f, ")")?; |
| 563 | return Ok(()); |
| 564 | } |
| 565 | |
| 566 | let nl = if pretty { '\n' } else { ' ' }; |
| 567 | let indent = if pretty { |
| 568 | String::from_utf8(vec![b' '; (width + 1) * 4]).unwrap() |
| 569 | } else { |
| 570 | String::new() |
| 571 | }; |
| 572 | write!(f, " {{{}", nl)?; |
| 573 | for (i, (attr, value)) in fields.iter().enumerate() { |
| 574 | if pretty { |
| 575 | write!( |
| 576 | f, |
| 577 | "{}{}: {:#width$}{}{}", |
| 578 | indent, |
| 579 | attr, |
| 580 | value, |
| 581 | ",", |
| 582 | nl, |
| 583 | width = (width + 1) |
| 584 | )?; |
| 585 | } else { |
| 586 | write!( |
| 587 | f, |
no test coverage detected