MCPcopy Index your code
hub / github.com/assert-rs/assert_cmd / write_debug_bstrs

Function write_debug_bstrs

src/output.rs:410–435  ·  view source on GitHub ↗
(
    f: &mut impl fmt::Write,
    multiline: bool,
    mut lines: impl Iterator<Item = &'a [u8]>,
)

Source from the content-addressed store, hash-verified

408}
409
410fn write_debug_bstrs<'a>(
411 f: &mut impl fmt::Write,
412 multiline: bool,
413 mut lines: impl Iterator<Item = &'a [u8]>,
414) -> fmt::Result {
415 if multiline {
416 writeln!(f, "```")?;
417 for mut line in lines {
418 let mut newline = false;
419 if line.last() == Some(&b'\n') {
420 line = &line[..line.len() - 1];
421 newline = true;
422 }
423 let s = format!("{:?}", line.as_bstr());
424 write!(
425 f,
426 "{}{}",
427 &s[1..s.len() - 1],
428 if newline { "\n" } else { "" }
429 )?;
430 }
431 writeln!(f, "```")
432 } else {
433 write!(f, "{:?}", lines.next().unwrap_or(&[]).as_bstr())
434 }
435}
436
437#[cfg(test)]
438mod test {

Callers 1

format_bytesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected