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

Function print_arr_items

protocol/src/value.rs:697–726  ·  view source on GitHub ↗
(
    f: &mut std::fmt::Formatter<'_>,
    data: &[RValue],
    width: usize,
    pretty: bool,
)

Source from the content-addressed store, hash-verified

695}
696
697fn print_arr_items(
698 f: &mut std::fmt::Formatter<'_>,
699 data: &[RValue],
700 width: usize,
701 pretty: bool,
702) -> std::fmt::Result {
703 write!(f, "[")?;
704 if data.is_empty() {
705 write!(f, "]")?;
706 return Ok(());
707 }
708 let indent = if pretty {
709 write!(f, "\n")?;
710 String::from_utf8(vec![b' '; (width + 1) * 4]).unwrap()
711 } else {
712 String::new()
713 };
714 for (i, item) in data.iter().enumerate() {
715 if pretty {
716 write!(f, "{}{:#width$},\n", indent, item, width = (width + 1))?;
717 } else {
718 write!(f, "{}{}", item, if i < data.len() - 1 { ", " } else { "" })?;
719 }
720 }
721 if pretty {
722 write!(f, "{}", String::from_utf8(vec![b' '; width * 4]).unwrap())?;
723 }
724 write!(f, "]")?;
725 Ok(())
726}
727
728fn print_bytes(f: &mut std::fmt::Formatter<'_>, bytes: &[u8]) -> std::fmt::Result {
729 write!(f, "[")?;

Callers 1

fmtMethod · 0.85

Calls 1

iterMethod · 0.45

Tested by

no test coverage detected