MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / fmt

Method fmt

cranelift/codegen/src/ir/constant.rs:127–135  ·  view source on GitHub ↗

Print the constant data in hexadecimal format, e.g. 0x000102030405060708090a0b0c0d0e0f. This function will flip the stored order of bytes--little-endian--to the more readable big-endian ordering. ``` use cranelift_codegen::ir::ConstantData; let data = ConstantData::from([3, 2, 1, 0, 0].as_ref()); // note the little-endian order assert_eq!(data.to_string(), "0x0000010203"); ```

(&self, f: &mut fmt::Formatter)

Source from the content-addressed store, hash-verified

125 /// assert_eq!(data.to_string(), "0x0000010203");
126 /// ```
127 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
128 if !self.is_empty() {
129 write!(f, "0x")?;
130 for b in self.0.iter().rev() {
131 write!(f, "{b:02x}")?;
132 }
133 }
134 Ok(())
135 }
136}
137
138impl FromStr for ConstantData {

Callers

nothing calls this directly

Calls 3

OkFunction · 0.85
is_emptyMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected