My binary resides as a string right now, I was hoping to format! it as an integer the same way I formatted my integer to binary: format!("{:b}", number).
I have a larger string of binary that I'm taking slices out of in a loop, so let's assume one of my slices is:
let bin_idx: &str = "01110011001";
I want to format that binary into an integer:
format!("{:i}", bin_idx);
This gives a compiler error:
error: unknown format trait `i`
--> src/main.rs:3:21
|
3 | format!("{:i}", bin_idx);
| ^^^^^^^
I also tried d and u and got the same error.