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

Function print_os_string

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

Source from the content-addressed store, hash-verified

648}
649
650fn print_os_string(
651 f: &mut std::fmt::Formatter<'_>,
652 fields: &IndexMap<String, RValue>,
653 width: usize,
654 pretty: bool,
655) -> std::fmt::Result {
656 write!(f, "{}::from_encoded_bytes_unchecked(", STD_OS_STRING)?;
657 if pretty {
658 write!(
659 f,
660 "\n{}",
661 String::from_utf8(vec![b' '; (width + 1) * 4]).unwrap()
662 )?;
663 }
664 let inner = match fields.get("inner") {
665 Some(RValue::Struct { fields, .. }) => {
666 if let Some(inner) = fields.get("inner") {
667 match inner {
668 RValue::Bytes { value, .. } => value,
669 _ => {
670 write!(f, "?)")?;
671 return Ok(());
672 }
673 }
674 } else {
675 write!(f, "?)")?;
676 return Ok(());
677 }
678 }
679 _ => {
680 write!(f, "?)")?;
681 return Ok(());
682 }
683 };
684 if let Ok(string) = std::str::from_utf8(inner) {
685 write!(f, "String::from({:?}).into_bytes()", string)?;
686 } else {
687 write!(f, "vec!")?;
688 print_bytes(f, inner)?;
689 }
690 if pretty {
691 write!(f, "\n{}", String::from_utf8(vec![b' '; width * 4]).unwrap())?;
692 }
693 write!(f, ")")?;
694 Ok(())
695}
696
697fn print_arr_items(
698 f: &mut std::fmt::Formatter<'_>,

Callers 1

fmtMethod · 0.85

Calls 2

print_bytesFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected