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)
| 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 | |
| 138 | impl FromStr for ConstantData { |