title: How do I convert an enum reference to a number?
body: <p>I have an enum:</p>
  
  <pre><code>enum Foo {
      Bar = 1,
  }
  </code></pre>
  
  <p>How do I convert a reference to this enum into an integer to be used in math?</p>
  
  <pre><code>fn f(foo: &amp;Foo) {
      let f = foo as u8;  // error[E0606]: casting `&amp;Foo` as `u8` is invalid
      let f = foo as &amp;u8; // error[E0605]: non-primitive cast: `&amp;Foo` as `&amp;u8`
      let f = *foo as u8; // error[E0507]: cannot move out of borrowed content
  }
  </code></pre>