title: Is there anything in Rust to convert a binary string to an integer?
body: <p>My binary resides as a string right now, I was hoping to <code>format!</code> it as an integer the same way I formatted my integer to binary: <code>format!("{:b}", number)</code>.</p>
  
  <p>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:</p>
  
  <pre><code>let bin_idx: &amp;str = "01110011001";
  </code></pre>
  
  <p>I want to format that binary into an integer:</p>
  
  <pre><code>format!("{:i}", bin_idx);
  </code></pre>
  
  <p>This gives a compiler error:</p>
  
  <pre class="lang-none prettyprint-override"><code>error: unknown format trait `i`
   --&gt; src/main.rs:3:21
    |
  3 |     format!("{:i}", bin_idx);
    |                     ^^^^^^^
  </code></pre>
  
  <p>I also tried <a href="https://doc.rust-lang.org/0.12.0/std/fmt/index.html" rel="noreferrer"><code>d</code> and <code>u</code></a> and got the same error.</p>