MCPcopy Create free account
hub / github.com/SeaQL/FireDBG.for.Rust / print_struct

Function print_struct

protocol/src/value.rs:530–600  ·  view source on GitHub ↗
(
    f: &mut std::fmt::Formatter<'_>,
    typename: &str,
    fields: &IndexMap<String, RValue>,
    width: usize,
    pretty: bool,
)

Source from the content-addressed store, hash-verified

528}
529
530fn 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,

Callers 2

fmtMethod · 0.85
print_hashmapFunction · 0.85

Calls 2

getMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected