MCPcopy Index your code
hub / github.com/BitVM/BitVM / fmt

Method fmt

bitvm/src/lib.rs:33–51  ·  view source on GitHub ↗
(&self, f: &mut fmt::Formatter)

Source from the content-addressed store, hash-verified

31pub struct FmtStack(pub Stack);
32impl fmt::Display for FmtStack {
33 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
34 let mut iter = self.0.iter_str().enumerate().peekable();
35 write!(f, "\n0:\t\t ")?;
36 while let Some((index, mut item)) = iter.next() {
37 if item.is_empty() {
38 write!(f, " [] ")?;
39 } else {
40 item.reverse();
41 write!(f, "0x{:8}", item.as_hex())?;
42 }
43 if iter.peek().is_some() {
44 if (index + 1) % f.width().unwrap_or(4) == 0 {
45 write!(f, "\n{}:\t\t", index + 1)?;
46 }
47 write!(f, " ")?;
48 }
49 }
50 Ok(())
51 }
52}
53
54impl FmtStack {

Callers

nothing calls this directly

Calls 3

is_emptyMethod · 0.80
lenMethod · 0.80
cloneMethod · 0.80

Tested by

no test coverage detected