title: How do I convert an unsigned integer to an integer in Rust?
body: <p>So I'm trying to get a random number, but I'd rather not have it come back as uint instead of int... Not sure if this match is right, either, but the compiler doesn't get that far because it's never heard of this from_uint thing I'm trying to do:</p>
  
  <pre><code>fn get_random(max: &amp;int) -&gt; int {
          // Here we use * to dereference max
          // ...that is, we access the value at 
          // the pointer location rather than
          // trying to do math using the actual
          // pointer itself
          match int::from_uint(rand::random::&lt;uint&gt;() % *max + 1) {
                  Some(n) =&gt; n,
                  None =&gt; 0,
          }
  }
  </code></pre>